You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Originally we updated it in the subscription handler so that we could
be sure it always represented the latest snapshot. However, we run into
problems because the `getSnapshot` could change the next time in the
same batch as the re-render, in which case the value is no longer
correct. So this moves it back to the commit phase.
We avoid the stale `getSnapshot` problem with a tearing check in the
commit phase whenever `getSnapshot` changes. Since `getSnapshot` is
designed to be fast, I combined both into a single `useLayoutEffect`,
along with the one we do when `subscribe` changes, to save some memory.
0 commit comments