UNPKG

@swc-jotai/react-refresh

Version:

SWC plugin for supporting React Refresh with Jotai

15 lines (14 loc) 327 B
globalThis.jotaiAtomCache = globalThis.jotaiAtomCache || { cache: new Map(), get(name, inst) { if (this.cache.has(name)) { return this.cache.get(name); } this.cache.set(name, inst); return inst; }, }; const myCustomAtom = globalThis.jotaiAtomCache.get( "atoms.ts/myCustomAtom", customAtom(0) );