Skip to content
Discussion options

You must be logged in to vote

export function getDefaultStore(): Store {
if (!defaultStore) {
defaultStore = createStore()
if (import.meta.env?.MODE !== 'production') {
;(globalThis as any).__JOTAI_DEFAULT_STORE__ ||= defaultStore
if ((globalThis as any).__JOTAI_DEFAULT_STORE__ !== defaultStore) {
console.warn(
'Detected multiple Jotai instances. It may cause unexpected behavior with the default store. https://github.com/pmndrs/jotai/discussions/2044',
)
}
}
}
return defaultStore
}

How about adding globalThis.__JOTAI_DEFAULT_STORE__ = null in your code?

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@mezei
Comment options

@dai-shi
Comment options

Answer selected by mezei
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants