I am trying to pass an input value for a form between 2 different react classes. The code below is working. The user types in their name to the form, click submit. they jump to a new view and the name they typed in is stored in state and can be retrieved as a prop. This works
<form onSubmit={this.handleClick}>
<input type="text" id="playerName" value={this.state.name} onChange={this.handleChange} placeholder="name" />
<input type="submit" value="submit" />
</form>
if (this.state.results){
output = <Decision name={this.state.value}/>;
}
handleChange: function(event){
this.setState({name: event.target.value})
},
My problem is that I want to to know add a new input type to the form. this time email.
However I cannot seem to replicate it with the same logic as I keep making errors.
if (this.state.results){
output = <Decision name={this.state.value} email={this.state.value}/>;
}
I tried adding a new prop (above) but when ever I typed in to the name field, this would also enter text into the email field (probably because I am updating the same state). How can I create an email prop and store and retrieve the state of this?
Can props be as simple as email={this.state.email}?