Skip to content
This repository was archived by the owner on Nov 10, 2021. It is now read-only.
This repository was archived by the owner on Nov 10, 2021. It is now read-only.

Reducing components rerenders #53

Closed
@goloveychuk

Description

@goloveychuk

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions