Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Invalid shared value access displaying when code is correct (#6631)
## Summary The problem was caused by our `useDerivedValue` hook which set ref to `null` in the `useEffect` cleanup method. ```tsx useEffect(() => { return () => { initRef.current = null; }; }, []); ``` The warning was shown during hot reload, because react calls cleanup functions in hooks, thus the `initRef` was reset in the `useDerivedValue` hook, which resulted in execution of this code that should run only when the component mounts for the first time: ```tsx if (initRef.current === null) { initRef.current = makeMutable(initialUpdaterRun(updater)); } ``` Because of that, `initialUpdaterRun` executed the `updater` callback on the JS thread during hot reload, while the component was rendered, which resulted in reading shared value's `.value` property during the render phase.
- Loading branch information