Skip to content

Broken componentWill(Did)Update #2974

Closed
@LKay

Description

@LKay

When updating state of the component the corresponding method from lifecycle get called but every time for any component the prevState or nextState is in fact always the same with the current state. So comparing them always return true. Mentioned methods should return correct objects for previous, next state.

getInitialState: function () {
    return {
        test: false
    };
}
someMethod: function () {
    this.setState({
        test: true
    });
}
componentDidUpdate: function (prevProps, prevState) {
    console.log(prevState.test === this.state.test); // Always true!
},

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