Update use-store-with-equality-fn.md (#3119)

This commit is contained in:
Danilo Britto 2025-05-12 16:54:39 -05:00 committed by GitHub
parent 2fcfc30530
commit 14feb61c7e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -709,7 +709,7 @@ given tab.
```tsx
const useCounterStore = <U,>(
currentTabIndex: number,
key: string,
selector: (state: CounterStore) => U,
) => {
const stores = useContext(CounterStoresContext)
@ -719,15 +719,11 @@ const useCounterStore = <U,>(
}
const getOrCreateCounterStoreByKey = useCallback(
() => createCounterStoreFactory(stores),
(key: string) => createCounterStoreFactory(stores!)(key),
[stores],
)
return useStoreWithEqualityFn(
getOrCreateCounterStoreByKey(`tab-${currentTabIndex}`),
selector,
shallow,
)
return useStore(getOrCreateCounterStoreByKey(key), selector)
}
```