Skip to content

Commit

Permalink
docs: fix batching example
Browse files Browse the repository at this point in the history
  • Loading branch information
bowheart committed May 10, 2024
1 parent 19f944b commit bff2272
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions docs/docs/advanced/batching.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,15 @@ const manualBatchingAtom = atom('manualBatching', () => {

// use `injectMemo` to "turn off" automatic batching:
// highlight-next-line
const updateTwice = injectMemo(() => {
ecosystem.batch(() => {
store.setState(state => state + 1)
store.setState(state => state + 1)
})
}, [])
const updateTwice = injectMemo(
() => () => {
ecosystem.batch(() => {
store.setState(state => state + 1)
store.setState(state => state + 1)
})
},
[]
)

return api(store).setExports({ updateTwice })
})
Expand Down

0 comments on commit bff2272

Please sign in to comment.