For memoization/performance consideration, using useSelector with ShallowEqual.
Will there be some more benefits for performance optimization using "Reselect/createSelector" option ?
Or both the options are same ?
Will have the data as JSON array objects at most of the selectors.
Before writing new selector , would like to consider performance/memoization benefits.
useSelectorwill prevent re-render ofMyComponentif theselectAndComputefunction computes the same result as last time it got triggered (and it gets triggered every time anything in redux state changes). But, this still requiresselectAndComputeto run and compute some result. This computation in itself might be expensive.So, you can add
reselect'screateSelectorto prevent even the computation done in theselectAndCompute. For example ifselectAndComputedepends only on the part of the statestate.transactionsyou can define:Now, only if
state.transactionshas changed the expensive computation will run, otherwiseselectAndComputewill immediately return the previous value. And finallyuseSelectorwill then block the re-render, same as it would ifreselectwas not used.