Summary
Tearing — UI shows mixed versions of external store during concurrent render (e.g. legacy Redux subscription). useSyncExternalStore forces consistent snapshot per render. TanStack Query / modern libraries handle this; ad-hoc global mutable stores may not. Symptom: flickering values, inconsistent list order during fast updates.
Code example
import { useSyncExternalStore } from 'react';
function useStoreValue(store) {
return useSyncExternalStore(
store.subscribe,
store.getSnapshot,
store.getServerSnapshot,
);
}
Key points
- Tearing — UI shows mixed versions of external store during concurrent render (e.g.
- legacy Redux subscription).
useSyncExternalStoreforces consistent snapshot per render.- TanStack Query / modern libraries handle this; ad-hoc global mutable stores may not.
- Symptom: flickering values, inconsistent list order during fast updates.