update state before view code example
Example 1: react lifecycle hooks
class Content extends React.Component {
// ...
componentWillMount() {
this.setState({ activities: data });
}
// ...
}
Example 2: reactjs update state example
{
hasBeenClicked: false,
currentTheme: 'blue',
}