move setting memoizedSnapshot

This commit is contained in:
daishi
2021-10-04 11:17:38 +09:00
parent a4bc8ae4c1
commit f01320689c
@@ -76,7 +76,6 @@ export function useSyncExternalStoreExtra<Snapshot, Selection>(
}
// 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<Snapshot, Selection>(
return prevSelection;
}
memoizedSnapshot = nextSnapshot;
memoizedSelection = nextSelection;
return nextSelection;
};