diff --git a/src/index.ts b/src/index.ts index 8151aa7..9bfbeb2 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,14 +1,5 @@ -import { __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED } from 'react'; import { useSyncExternalStore } from 'use-sync-external-store/shim'; -declare module 'react' { - var __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: { - ReactCurrentOwner: { - current: null | unknown; - }; - }; -} - type VoidFn = () => void; type AnyFn = (...args: unknown[]) => unknown; @@ -118,12 +109,9 @@ const resso = >(obj: Obj): Store => { return obj[key]; } - if ( - __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner - .current !== null - ) { + try { return state[key].useSnapshot(); - } else { + } catch (err) { return obj[key]; } }