react set state before render code example
Example: react set state before render
componentDidMount() {
this.setState({
thing: [
{
status: "running",
test: "testing"
}
]
});
}
render() {
return (
{this.state.thing.length > 0? { this.state.thing[0].status }: null
}
);
}