A hook for tracking a subpart or a computed value derived from the
RootState of a Store by a
Selector function.
This hook calls selector with the Store's RootState and returns the
derived value. Then it watches the store, calling
the selector again for every change to the RootState. If the value
returned by selector is not identical to the last saved value, a re-render
will be triggered (and this hook will return the new value).
If your selector constructs a new data structure based on the RootState,
(rather than just selecting some part of the ImmutableRootState or
calculating a primitive value), then it might return a non-identical value
even when nothing has changed. Computed data structures should be
memoized
to minimise component refreshes.
A hook for tracking a subpart or a computed value derived from the RootState of a Store by a Selector function.
This hook calls
selector
with theStore
'sRootState
and returns the derived value. Then it watches the store, calling theselector
again for every change to theRootState
. If the value returned byselector
is not identical to the last saved value, a re-render will be triggered (and this hook will return the new value).If your
selector
constructs a new data structure based on theRootState
, (rather than just selecting some part of the ImmutableRootState
or calculating a primitive value), then it might return a non-identical value even when nothing has changed. Computed data structures should be memoized to minimise component refreshes.See Selector