useStoreMap
React hook, which subscribes to store and transforms its value with given function. Component will update only when selector function result will change
Common use case: subscribe to changes in selected part of store only
note
Short version of useStoreMap
introduced in effector-react@21.3.0
Arguments
store
: Source storefn
((state) => result): Selector function to receive part of source store
Returns
(Result)
Overload used when you need to pass dependencies to react (to update items when some of its dependencies are changed)
Arguments
params
(Object): Configuration objectstore
: Source storekeys
(Array): This argument will be passed to React.useMemo to avoid unnecessary updatesfn
((state, keys) => result): Selector function to receive part of source storeupdateFilter
((newResult, oldResult) => boolean): Optional function used to compare old and new updates to prevent unnecessary rerenders. Uses createStore updateFilter option under the hood
Returns
(Result)
note
updateFilter
option introduced in effector-react@21.3.0
#
ExampleThis hook is very useful for working with lists, especially with large ones