Created
July 5, 2018 01:31
-
-
Save MostlyFocusedMike/f581908eb28e8716da615c001426b49e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//...state... | |
addCat = (e) => { | |
this.setState((prevState) => ({ | |
cats: [...prevState.cats, {name:"", age:""}], | |
})); | |
} | |
handleSubmit = (e) => { e.preventDefault() } | |
render() { | |
let {cats} = this.state | |
return ( | |
<form onSubmit={this.handleSubmit}> | |
<label htmlFor="name">Owner</label> | |
<input type="text" name="owner" id="owner" /> | |
<label htmlFor="description">Description</label> | |
<input type="text" name="description" id="description" /> | |
<button onClick={this.addCat}>Add new cat</button> | |
//...rest of render... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment