In plain words
Destructuring pulls named values out of an object or array in one line, and spread, the three dots, copies everything from one into another.
Where you see it
Nearly every Supabase call your agent writes begins with const { data, error }. That's destructuring: it takes two keys from the response and gives each a name. The three dots in setNote({ ...note, title }) are spread, copying the old note and replacing one field.
What goes wrong
- Spreading in the wrong order
{ title: newTitle, ...note } puts the old title back on top of the new one, so the edit never sticks. Spread first, changes after.
- Destructuring something that isn't there yet
const { name } = member throws "Cannot destructure property 'name'" when member is undefined. Wait for the data, or fall back to an empty object.
const { name } = member ?? {}; - Reading a rename as something else
In const { data: notes } = ..., the colon renames data to notes. It isn't a type, and there's no variable called data afterwards.
What to tell your agent
Quick check
Sign in to earn +10 XP for itMaya renames a Quill note, but the old title comes back after saving. The code builds { title: newTitle, ...note }. Why?