Skip to content

Use ReactDOM.unstable_batchedUpdates in useRouterHistory? #2919

@taion

Description

@taion

From reactjs/react-router-redux#197.

This issue arises when using a Flux integration for React Router. The issue is that, if the integration updates e.g. Flux stores when history updates, this will lead to a separate setState (in e.g. smart component containers, from the store update) from the setState in <Router> (from the transition manager update directly), which will lead to the page rendering twice.

We could in principle resolve this by using ReactDOM.unstable_batchedUpdates in useRouterHistory. We can't really do this in history because that library is not aware of React. I think it'd make more sense to do it here rather than in every React Router integration, because otherwise they'd all need the same logic.

The downsides of course are:

  • We now call into an unstable API
  • We introduce an explicit react-dom dependency (for now) when currently there isn't one

cc @gaearon, in case this is a horrible anti-pattern if used in conjunction with Redux

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature-requestUsed to close PRs that haven't gone through/been accepted the Proposal process yet

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions