Skip to content

ReactCurrentOwner set before constructor call causes false warnings #5313

@gaearon

Description

@gaearon

ReactCurrentOwner is set before the constructor call. If a constructor has side effects like a Flux Store dispatch, then other components may get their setState() called. They will log a warning that setState() cannot be called from render().

This warning is misleading because this is not what happened. It protects against setState() calls from render() but what really happens is one component causing a side effect in its constructor, leading to other component getting its setState() called, which shouldn't result in a warning.

I'm not sure it's worth fixing but something #5302 reminded me about.
Original issue: reduxjs/react-redux#129 (comment).

Warning message:

Warning: setState(...): Cannot update during an existing state transition (such as within render). Render methods should be a pure function of props and state.

Per reduxjs/react-redux#129 (comment), the issue is new to 0.14.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions