1// Correct
2this.setState(function(state, props) {
3 return {
4 counter: state.counter + props.increment
5 };
6});
1You have to use setState() for updating state in React
2{
3 hasBeenClicked: false,
4 currentTheme: 'blue',
5}
6
7setState({
8 hasBeenClicked: true
9});
10
1function tick() {
2 const element = (
3 <div>
4 <h1>Hello, world!</h1>
5 <h2>It is {new Date().toLocaleTimeString()}.</h2>
6 </div>
7 );
8 ReactDOM.render( element, document.getElementById('root') );}
9
10setInterval(tick, 1000);
1You have to use setState() for updating state in React
2{
3 hasBeenClicked: false,
4 currentTheme: 'blue',
5}
6
7setState({
8 hasBeenClicked: true
9});