Tell us what’s happening:
I was able to pass the challenge, I just have a question about the form and the double use of onChange so let’s focus on that
Form tag has a submit that goes to {this.onChange}
and input value uses onChange to fire the method {this.handleChange}
So my question is am I nesting onChange? Is the form on submit firing onChange last, after the this.onChange finishes the return from this.handleChange?
When does the form {this.onChange} get linked to the {this.handleChange}?
Your code so far
class ControlledInput extends React.Component {
constructor(props) {
super(props);
this.state = {
input: ''
};
// change code below this line
// change code above this line
}
// change code below this line
// change code above this line
render() {
return (
<div>
{ /* is this.onChange being overrided by the input line? */}
<form onSubmit = {this.onChange} >
<input value = {this.state.input} onChange = {this.handleChange} />
</form>
{ /* change code above this line */}
<h4>Controlled Input:</h4>
<p>{this.state.input}</p>
</div>
);
}
};
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36
.
Link to the challenge:
https://learn.freecodecamp.org/front-end-libraries/react/create-a-controlled-input