From f89840c2d6c43c3e65d1634ffec6633ea47e1937 Mon Sep 17 00:00:00 2001 From: Joe Anderson Date: Thu, 21 Dec 2023 18:46:43 +0000 Subject: [PATCH] Fix: Should not warn if store is undefined in getter --- packages/jotai-x/src/createAtomStore.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/jotai-x/src/createAtomStore.ts b/packages/jotai-x/src/createAtomStore.ts index 8d5f61d..7dcfb84 100644 --- a/packages/jotai-x/src/createAtomStore.ts +++ b/packages/jotai-x/src/createAtomStore.ts @@ -224,14 +224,17 @@ export const createAtomStore = < const setAtoms = {} as SetRecord; const useAtoms = {} as UseRecord; - const useStore = (optionsOrScope: UseAtomOptionsOrScope = {}) => { + const useStore = ( + optionsOrScope: UseAtomOptionsOrScope = {}, + warnIfUndefined = true + ) => { const { scope, store } = convertScopeShorthand(optionsOrScope); - const contextStore = useAtomStore(name, scope); + const contextStore = useAtomStore(name, scope, warnIfUndefined); return store ?? contextStore; }; const useAtomValueWithStore: GetAtomFn = (atomConfig, optionsOrScope) => { - const store = useStore(optionsOrScope); + const store = useStore(optionsOrScope, false); const { delay = delayRoot } = convertScopeShorthand(optionsOrScope); return useAtomValue(atomConfig, { store, delay }); };