Uncaught TypeError: Cannot read property 'strikes' of undefined at timerTriker (APP3.js:19)
import React from 'react';
class LightCounter extends React.Component{
constructor(props){
super(props);
this.state={
strikes:0
}
}
getInitialState(){
return {
strikes:0
}
}
timerTriker(){
this.setState({
strikes:this.state.strikes+100
})
}
componentDidMount(){
setInterval(this.timerTriker,1000)
}
render(){
return (
<div>
<h1>{this.state.strikes}</h1>
</div>
)
}
}
class LightCounterDisplay extends React.Component{
render(){
var divStyle ={
width:250,
textAlign:"center",
backgroundColor:"black",
padding:40,
color:"#999",
fontFamily:"sans-serif",
borderRadius:10
}
return (
<div style= {divStyle}>
<LightCounter />
</div>
)
}
}
export default LightCounterDisplay