Skip to content

Commit

Permalink
match the typescript docs (#2856)
Browse files Browse the repository at this point in the history
  • Loading branch information
charkour authored Nov 17, 2024
1 parent 5a8842f commit 7980a7b
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions docs/migrations/migrating-to-v5.md
Original file line number Diff line number Diff line change
Expand Up @@ -180,11 +180,14 @@ store.setState({}, true) // Error
#### Handling Dynamic `replace` Flag
If the value of the `replace` flag is dynamic and determined at runtime, you might face issues. To handle this, you can use a workaround by annotating the `replace` parameter with `as any`:
If the value of the `replace` flag is dynamic and determined at runtime, you might face issues. To handle this, you can use a workaround by annotating the `replace` parameter with the parameters of the `setState` function:
```ts
const replaceFlag = Math.random() > 0.5
store.setState(partialOrFull, replaceFlag as any)
const args = [{ bears: 5 }, replaceFlag] as Parameters<
typeof useBearStore.setState
>
store.setState(...args)
```
#### Persist middlware no longer stores item at store creation
Expand Down

0 comments on commit 7980a7b

Please sign in to comment.