Skip to content
This repository was archived by the owner on Jun 24, 2024. It is now read-only.
This repository was archived by the owner on Jun 24, 2024. It is now read-only.

♻ Consider rewriting the hooks based connect on react-redux #342

@diescake

Description

@diescake

Consider rewriting the hooks based connect on react-redux. Recently, the react-redux introduces new hooks based API useSelector and useDispatch. They can replace connect, and it seems more friendly for function components.

However, according to the document, useSelector is not the completely compatibles for mapState functions. As follows.

  • The selector may return any value as a result, not just an object. The return value of the selector will be used as the return value of the useSelector() hook.
  • When an action is dispatched, useSelector() will do a reference comparison of the previous selector result value and the current result value. If they are different, the component will be forced to re-render. If they are the same, the component will not re-render.
  • The selector function does not receive an ownProps argument. However, props can be used through closure (see the examples below) or by using a curried selector.
  • Extra care must be taken when using memoizing selectors (see examples below for more details).
  • useSelector() uses strict === reference equality checks by default, not shallow equality (see the following section for more details).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions