4.1/5 Is there anyone who can explain how it works?


#1

So, we want to select another option from the drop-down menu for that option to be written on top of the page. In Parent.js, we call the Child component within render() function. And in Child.js, we need to create an event listener so that the changes will take effect. And eventually, a child component will change the state of its parent component. BUT, in Child.js, why do we need to write this line:

{this.props.onChange}

Why can’t I write {this.props.changeName} so that it can invoke changeName()? What’s the value of {this.props.onChange} or how does the rest of the chain reaction continue?


#2

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.