Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialerkany
7,189 PointsHow name argument passing through App.js from AddPlayerForm class?
In AddPlayerForm class, handleAddPlayer function has an argument 'name' that pass this.state.value. Whatever the value of this.state.value in that time will be passed to addPlayer function and called.
handleSubmit = (e) => {
e.preventDefault();
this.props.addPlayer(this.state.value);
this.setState({value: ''});
console.log('Handle submit' + this.state.value);
}
My question is how this.state.value has been passed to handleAddPlayer function in App.js? Is it because of reference issue in props?
<AddPlayerForm addPlayer={this.handleAddPlayer}/>
1 Answer
erkany
7,189 PointsYes Brandon, that was a question but I watched the videos several times and I think I got it. Sometimes javascript confuses me with other programming languages especially for function expression.
Thank you.
Brandon White
Full Stack JavaScript Techdegree Graduate 34,662 PointsBrandon White
Full Stack JavaScript Techdegree Graduate 34,662 PointsHi erkany,
I’m a bit confused about what you’re asking. Are you wanting to know how to pass an argument into the handleAddPlayer method?