Welcome aboard! We are happy you are here and wish you good net-raft!
import React from 'react';
class App extends React.Component {
constructor() {
super();
this.state = {
data: []
}
this.handleChange = this.handleChange.bind(this);
};
handleChange({target}) {
var msg;
if (target.checked) {
msg = "checked";
this.setState({data: msg})
} else {
msg = "unchecked";
this.setState({data: msg})
}
};
render() {
return (
<div>
<input type="checkbox"
onClick={this.handleChange}
defaultChecked={this.props.complete}
/>
<h2>{this.state.data}</h2>
</div>
);
}
}
export default App;
The most helpful REACT solutions
How to get client ip address using react ?REACT Click to see more ... 19.2K 421