Skip to content

Commit

Permalink
docs: add note regarding accessor (#4521)
Browse files Browse the repository at this point in the history
  • Loading branch information
jzhan-canva authored Feb 11, 2025
1 parent e01114a commit 09edf2b
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions docs/enabling-decorators.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,24 +39,24 @@ With modern decorators, it is no longer needed to call `makeObservable` / `makeA
}
```

- Vite configuration
- Vite configuration

```js
// vite.config.js
{
plugins: [
react({
babel: {
plugins: [
[
"@babel/plugin-proposal-decorators",
{
version: "2023-05",
},
],
],
},
}),
react({
babel: {
plugins: [
[
"@babel/plugin-proposal-decorators",
{
version: "2023-05"
}
]
]
}
})
]
}
```
Expand Down Expand Up @@ -140,6 +140,8 @@ To migrate from legacy decorators to modern decorators, perform the following st
2. Remove all `makeObservable(this)` calls from class constructors that use decorators.
3. Replace all instances of `@observable` (and variations) with `@observable accessor`

Please note that adding `accessor` to a class property will change it into `get` and `set` class methods. Unlike class properties, class methods are not enumerable. This may introduce new behavior with some APIs, such as `Object.keys`, `JSON.stringify`, etc.

</details>

<details id="gotchas"><summary>Decorator changes / gotchas</summary>
Expand Down

0 comments on commit 09edf2b

Please sign in to comment.