Skip to content

Commit d8182cc

Browse files
committed
chore: update comments
1 parent 30dd62f commit d8182cc

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/app/store/selector/useSyncExternalStoreWithSelector.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Simplified fork of the useSyncExternalStore hook from the official package,
22
// with `getServerSnapshot` parameter removed and `instRef` simplified using a symbol.
3-
// https://github.com/facebook/react/blob/be8aa76873e231555676483a36534bb48ad1b1a3/packages/use-sync-external-store/src/useSyncExternalStoreWithSelector.js
3+
// https://github.com/facebook/react/blob/8d74e8c73a5cc5e461bb1413a74c6b058c6be134/packages/use-sync-external-store/src/useSyncExternalStoreWithSelector.js
44
// MIT Licensed https://github.com/facebook/react/blob/be8aa76873e231555676483a36534bb48ad1b1a3/LICENSE
55

66
import { useDebugValue, useEffect, useMemo, useRef, useSyncExternalStore } from 'react'
@@ -54,10 +54,13 @@ export function useSyncExternalStoreWithSelector<Snapshot, Selection>(
5454
// The snapshot has changed, so we need to compute a new selection.
5555
const nextSelection = selector(nextSnapshot)
5656

57-
// Use the provided isEqual function to check if the data has changed. If
58-
// it hasn't, return the previous selection. That signals to React that
59-
// the selections are conceptually equal, and we can bail out of rendering.
57+
// If a custom isEqual function is provided, use that to check if the data
58+
// has changed. If it hasn't, return the previous selection. That signals
59+
// to React that the selections are conceptually equal, and we can bail
60+
// out of rendering.
6061
if (isEqual(prevSelection, nextSelection)) {
62+
// The snapshot still has changed, so make sure to update to not keep
63+
// old references alive
6164
memoizedSnapshot = nextSnapshot
6265
return prevSelection
6366
}

0 commit comments

Comments
 (0)