YousefED / SyncedStore

SyncedStore CRDT is an easy-to-use library for building live, collaborative applications that sync automatically.

Home Page:https://syncedstore.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

errors nextjs

UXDart opened this issue · comments

commented

Hello. I'm having a lot of errors. found the errors to happen when calling to useSyncedStore() in different components at the same screen, same store. this is on last React and NextJS

Unhandled Runtime Error
TypeError: Cannot read properties of null (reading 'removeObservers')

Call Stack
eval
node_modules/@reactivedata/react/dist/reactive-react-bindings.module.js (35:0)
safelyCallDestroy
node_modules/next/dist/compiled/react-dom/cjs/react-dom.development.js (19741:0)
commitHookEffectListUnmount
node_modules/next/dist/compiled/react-dom/cjs/react-dom.development.js (19923:0)
commitHookPassiveUnmountEffects
node_modules/next/dist/compiled/react-dom/cjs/react-dom.development.js (22550:0)
commitPassiveUnmountInsideDeletedTreeOnFiber
node_modules/next/dist/compiled/react-dom/cjs/react-dom.development.js (22750:0)
commitPassiveUnmountEffectsInsideOfDeletedTree_begin
node_modules/next/dist/compiled/react-dom/cjs/react-dom.development.js (22706:0)
recursivelyTraversePassiveUnmountEffects
node_modules/next/dist/compiled/react-dom/cjs/react-dom.development.js (22568:0)
commitPassiveUnmountOnFiber
node_modules/next/dist/compiled/react-dom/cjs/react-dom.development.js (22629:0)
recursivelyTraversePassiveUnmountEffects
node_modules/next/dist/compiled/react-dom/cjs/react-dom.development.js (22582:0)
commitPassiveUnmountOnFiber
node_modules/next/dist/compiled/react-dom/cjs/react-dom.development.js (22596:0)
recursivelyTraversePassiveUnmountEffects
node_modules/next/dist/compiled/react-dom/cjs/react-dom.development.js (22582:0)
commitPassiveUnmountOnFiber
node_modules/next/dist/compiled/react-dom/cjs/react-dom.development.js (22629:0)

there seems to be a loop. I saw that some hooks are using the concept of being "mounted" something that doesn't work for some time in React 18. the two questions are, 1) is it possible to call removeObservers only if the parent is still there? b) is it being unmounted and removed without removing observers now?

I will try to add a ? here for example, but I'm not sure if it is only that or an edge case is happening?

return () => {
  mounted.current = false;
  observer.current?.removeObservers();
  observer.current = null;
};

Thanks