set state in react js code example
Example 1: state in react
class BalanceInquiry extends Component {
constructor(props) {
super(props);
this.state = {
totalIncome: 0,
};
}
render() {
return <div>totalIncome {this.state.totalIncome}</div>;
}
}
Example 2: set state
setState({ searchTerm: event.target.value })