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 trialUmidjon Khaitov
8,884 PointsText field is not getting cleared up after Submit event
I think here is the main part which should clear up input field. Other than that I'm kinda lost, don't know how to find this bug. I tried to console log(this.setState({ value: ''})) as a last statement in this function, it says undefined.
handleSubmit = (e) => {
e.preventDefault();
this.props.addPlayer(this.state.value);
this.setState({ value: ''});
}
1 Answer
Edith Allison
2,946 PointsDid you follow the code at around 7:15 minutes of the video? You need to change
handleSubmit = (e) => {
e.preventDefault();
this.props.addPlayer(this.state.value);
}
to
handleSubmit = (e) => {
e.preventDefault();
this.props.addPlayer(this.state.value);
this.setState({
value: ''
});
}
Umidjon Khaitov
8,884 Pointsyeah you were right! thank you!
Dom Ss
4,339 PointsDom Ss
4,339 PointsTry console log the value like this in the render method.
Also double-check your :
I saw some answers were people changed
to
and it worked. O.o
Make sure there are NO TYPOS in any of the "value" keyword. ;)