Skip to content

Unnecessary call to selectStateProps when using useSelector #22

@objectliteral

Description

@objectliteral

While working on #21 I found that the selectStateProps functions that are passed to useSelector, currently, get executed twice for each relevant key change. This is due to useSelector (which is already reading state using useState) always calling it once and the callback given to the store proxy calling it to detect changes; if changes are found, the callback sets the state resulting in the entire selectStateProps function to be executed again.

This should be fixed such that for each relevant store key change, selectStateProps is only called once.

The impact is probably not that huge since the return value of the two selectStateProps calls will always be the same, causing React to only trigger (at most) one rerender.

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingperformancePerformance optimization

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions