Reducing components rerenders #53
Description
Looks like we can reduce component rerenders count by removing useEffect
from here
https://github.com/facebookincubator/redux-react-hook/blob/676a270be12f0bcbffe9d650ef769d6dd486ef70/src/create.ts#L91-L94
Since useEffect
will execute somewhen in the future after component renders, even if our hook already returned new state,
https://github.com/facebookincubator/redux-react-hook/blob/676a270be12f0bcbffe9d650ef769d6dd486ef70/src/create.ts#L110
still compares to old.
In practice, for my case, with using 6 hooks and 4 dispatches, it's reducing rerenders counts from 6 to 4.
here is used useLayoutEffect
https://github.com/reduxjs/react-redux/blob/06a674e733454b08bb4090f8bcb038a3a003e6aa/src/hooks/useSelector.js#L79-L85
Which seems to work correctly too.