Answer the question
In order to leave comments, you need to log in
How to fix React code and use babel?
Tell me, I'm going through react lessons and this code does not work, the error, as I understand it, is in setting up webpack or babel , here's the code
import React , { Component } from 'react';
class SearchBar extends Component {
constructor(props) {
super(props);
this.state={ term: ' ' };
}
render() {
return {
<div>
<input onChange={event => this.setState( { term:event.target.value} ) }/>;
val of inp:
</div>
};
}
}
export default SearchBar;
Answer the question
In order to leave comments, you need to log in
import React, { Component } from 'react';
class SearchBar extends Component {
constructor(props) {
super(props);
this.state = { term: ' ' };
}
render() {
return ( // в круглых скобках возвращаем, если более 1й строки
<div>
<input onChange={event => this.setState({ term: event.target.value })} />;
</div>
)
}
}
export default SearchBar;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question