Console.log printing the incremented value, but value not updated in button
'use strict';
const e = React.createElement;
class Counter extends React.Component {
constructor(props) {
super(props);
this.state = { val: 0 };
}
render() {
return e(
'button',
{
onClick: () => {
this.state.val = this.state.val + 1
console.log(this.state.val)
}
},
'Like' + this.state.val // here Like 1 should be displayed
);
}
}
const domContainer = document.querySelector('#root');
ReactDOM.render(e(Counter), domContainer);