From bff22728014b5b2456fd5c5b3dad4ddda52a54c6 Mon Sep 17 00:00:00 2001 From: Joshua Claunch Date: Fri, 10 May 2024 09:33:15 -0400 Subject: [PATCH] docs: fix batching example --- docs/docs/advanced/batching.mdx | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/docs/docs/advanced/batching.mdx b/docs/docs/advanced/batching.mdx index 37ffb17d..9e4e2232 100644 --- a/docs/docs/advanced/batching.mdx +++ b/docs/docs/advanced/batching.mdx @@ -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 }) })