Skip to content

Commit

Permalink
add note about destructuring breaking reactivity (#986)
Browse files Browse the repository at this point in the history
  • Loading branch information
brenelz authored Dec 17, 2024
1 parent 1f0d66b commit cba901d
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/routes/concepts/components/props.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ Instead, you should access props directly from the `props` object, or wrap them

```typescript
function MyComponent(props) {
const name = props.name; // ❌: breaks reactivity and will not update when the prop value changes
const { name } = props; // ❌: breaks reactivity and will not update when the prop value changes
const name = props.name; // ❌: another example of breaking reactivity
const name = () => props.name; // ✓: by wrapping `props.name` into a function, `name()` always retrieves its current value
}
```
Expand Down

0 comments on commit cba901d

Please sign in to comment.