Skip to content

How do batched updates work? #891

@OliverJAsh

Description

@OliverJAsh

I am curious whether React Redux utilises batched updates in any way. I want to know whether I need to be worried about multiple render cycles happening when dispatching a single action. There are a few other issues concerning this, however they appear to be related to the old version of this library, and they don't detail the exact workings.

Here is my current understanding. Please tell me where I am wrong!

Each instance of Connect will call its onStateChange method when the Redux state changes, which internally will call setState if the props have changed.

This means we will be calling setState for many instances of the Connect component, all within the same call frame.

As far as I understand it, React only implements batching for multiple setState calls in the same event handler sequence. In our case, the setState calls happen outside of an event handler, so each instance of Connect which needs updating will trigger its own render cycle when calling setState.

Do I understand correctly? I don't believe I do, because in my own profiling it appears there is only one render cycle…

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