Answer the question
In order to leave comments, you need to log in
Why doesn't React code work after some changes towards es6?
I tried to write in React using the examples here - it worked.
Now I tried to rewrite it a little closer to ES6 - it doesn't work.
Where did I mess up?
Answer the question
In order to leave comments, you need to log in
It should be something like this
.
The main problem is that getInitialState is replaced with a constructor and there is no autobinding in the ES6 syntax, so either use .bind(this) or arrow functions:
handleChange = (e) => {
this.setState({val: e.target.value});
}
tick = () => {
this.setState({
first: new Date() - this.state.start
});
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question