diff --git a/packages/use-sync-external-store/src/useSyncExternalStoreExtra.js b/packages/use-sync-external-store/src/useSyncExternalStoreExtra.js index f4a1885aec5b9..aa4957b534753 100644 --- a/packages/use-sync-external-store/src/useSyncExternalStoreExtra.js +++ b/packages/use-sync-external-store/src/useSyncExternalStoreExtra.js @@ -76,7 +76,6 @@ export function useSyncExternalStoreExtra( } // The snapshot has changed, so we need to compute a new selection. - memoizedSnapshot = nextSnapshot; const nextSelection = selector(nextSnapshot); // If a custom isEqual function is provided, use that to check if the data @@ -87,6 +86,7 @@ export function useSyncExternalStoreExtra( return prevSelection; } + memoizedSnapshot = nextSnapshot; memoizedSelection = nextSelection; return nextSelection; };