Skip to content

Nested connect updates are not batched #1510

Closed
@OliverJAsh

Description

Do you want to request a feature or report a bug?

(If this is a usage question, please do not post it here—post it on Stack Overflow instead. If this is not a “feature” or a “bug”, or the phrase “How do I...?” applies, then it's probably a usage question.)

Bug

What is the current behavior?

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem. Your bug will get fixed much faster if we can run your code and it doesn't have dependencies other than React. Paste the link to a CodeSandbox (https://codesandbox.io/s/new) or RN Snack (https://snack.expo.io/) example below:

https://stackblitz.com/edit/react-redux-batching-xkhtq8?file=index.tsx

What is the expected behavior?

  1. Open https://react-redux-batching-xkhtq8.stackblitz.io/
  2. Open dev tools -> React profiler
  3. Click "reload and start profiling"
  4. After reload, end profiling

Expected: 2 commits:

  1. First render
  2. Counter and ReduxCounter update, triggered via dispatch inside Counter#componentDidMount

Actual: 3 commits:

  1. First render
  2. Counter update, triggered via dispatch inside Counter#componentDidMount
  3. ReduxCounter update, triggered via dispatch inside Counter#componentDidMount

IIUC, there is no reason why 2 and 3 can not be batched into a single React re-render?

Screen Recording 2020-01-28 at 16 30 28

Which versions of React, ReactDOM/React Native, Redux, and React Redux are you using? Which browser and OS are affected by this issue? Did this work in previous versions of React Redux?

image

Update: note this issue does not occur when using useSelector. https://stackblitz.com/edit/react-redux-batching-zb1wxv?file=index.tsx

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