Content
Classified in Computers
Written at on English with a size of 1.43 KB.
class BookAddForm extends Component {
constructor(props){
super(props)
this.state = {
title : '',
content : ''
}
this.HandleChange = (evt) => {
this.SetState({
[evt.Target.Name] : evt.Target.Value
})
}
}
render() {
return (
<div>
<form>
<label for="title">My title</label>
<input type="text" name="title" id="title" onChange={this.HandleChange} />
<label for="content">My content</label>
<input type="text" name="content" id="content" onChange={this.HandleChange} />
<input type="button" value="add" onClick={() => this.Props.OnAdd({
title : this.State.Title,
content : this.State.Content
})} />
</form>
</div>
)
}
}