Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Dom Ss
4,339 PointsWhat is being passed where in state/value?
So when I name differently value property, also the props from the form I still get an updated state object and no errors. For example, this does not give me any errors. Why?
`class AddPlayerForm extends Component {
state = {
value2: ''
};
handleValueChange = (e) => {
this.setState(
{ value2: e.target.value }
);
}
render () {
console.log(this.state.value2, 'value')
return (
<form>
<input
type="text"
value1={this.state.value3}
onChange={this.handleValueChange}
placeholder="Enter a player name"
/>
<input
type="submit"
value="Add Player"
/>
</form>
);
}
}`
1 Answer

Zimri Leijen
11,772 PointsonChange={this.handleValueChange}
will call the function handleValueChange
when the text input is changed.
which will trigger this
this.setState(
{ value2: e.target.value }
);
which sets the value2 key in the state to the value of the event that triggered it.
Dom Ss
4,339 PointsDom Ss
4,339 PointsThank you Zimri,
so "value3" from
value1={this.state.value3}
does not have to match to "value2" from
?
Zimri Leijen
11,772 PointsZimri Leijen
11,772 Pointscorrect, I don't even think
value1={this.state.value3}
does anything at all