Skip to content

[10.0.0-alpha.2] - setState() doesn't apply state when called within componentWillMount #1461

@tmtek

Description

@tmtek

In 10.0.0-alpha.2, state does not set properly from componentWillMount. It seems this has been experienced by others in the past in componentWillReceiveProps. Here's a simple test case:

export class TestComponent extends Component {
    
    //This does not work:
    componentWillMount() {
        this.setState({message:"componentWillMount"});
    }

    /*
    //This works:
    componentDidMount() {
        this.setState({message:"componentDidMount"});
    }
    */
    
    render() {
        return <p>State came through from {this.state.message || 'nothing =('}</p>;
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions