From 3e68ccca9297ff9a95e68f2a521dc23538c54c00 Mon Sep 17 00:00:00 2001 From: Benson Date: Thu, 30 Nov 2023 11:10:58 +0800 Subject: [PATCH] docs: fix dispatchAtom example (#2284) --- docs/guides/composing-atoms.mdx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/guides/composing-atoms.mdx b/docs/guides/composing-atoms.mdx index 4344053903..9522ba133b 100644 --- a/docs/guides/composing-atoms.mdx +++ b/docs/guides/composing-atoms.mdx @@ -182,12 +182,12 @@ You can also create an action atom that will call another action atom: export const dispatchAtom = atom(null, (_get, set, action) => { if (action === 'INC') { set(incAtom) - } - if (action === 'DEC') { + } else if (action === 'DEC') { set(decAtom) + } else { + throw new Error('unknown action') } - throw new Error('unknown action') -} +}) ``` Why do we want it? Because it will be used only when needed.