diff --git a/src/vanilla/store.ts b/src/vanilla/store.ts index 39e55795c6..5b0c47cf17 100644 --- a/src/vanilla/store.ts +++ b/src/vanilla/store.ts @@ -680,6 +680,9 @@ const buildStore = ( export const createStore = (): Store => { const atomStateMap = new WeakMap() const getAtomState = (atom: Atom) => { + if (import.meta.env?.MODE !== 'production' && !atom) { + throw new Error('Atom is undefined or null') + } let atomState = atomStateMap.get(atom) as AtomState | undefined if (!atomState) { atomState = { d: new Map(), p: new Set(), n: 0 }