JSFiddle - React, Tailwind, and code Playground
JavaScript
class Timer extends React.Component {
constructor(props){
super(props);
//this.state = {value : 0}
this.state = {
count: 5,
value : this.props.num
}
this.increment = function(){
this.setState({
count: ++this.state.count,
value : this.state.value + 500
})
console.log('werwt')
}.bind(this)
}
render(){
let num = this.state.count
return (
<div>
<p>Это таймер</p>
<span>{num}</span>
<br/>
<span>{this.state.value}</span>
<p>2222</p>
<button onClick = {this.increment} >Кнопка</button>
</div>
)}
}
ReactDOM.render( React.createElement(Timer, {num : 500}), document.getElementById('root'));