React Set State Avant Render
componentDidMount() {
this.setState({
thing: [
{
status: "running",
test: "testing"
}
]
});
}
render() {
return (
<div>
{this.state.thing.length > 0? <h1 className="mt-5 mb-5">{ this.state.thing[0].status }</h1>: null
}
<button className="mt-5" onClick={ this.handleUpdate } value="not running">
Click to change
</button>
</div>
);
}
Proud Platypus