Passing Functions Downstream in React
Simple example of how to pass a event handler from a parent component to a child component:
When the app renders, the button also renders. When the button is clicked, here is the chain of event that cascades starting from the button’s onClick
definition
this.clickHandler
on line 22this.props.clicked
on line 23 references{this.handleClick}
from the app, per definition on line 16this.handleClick(input)
on line 10alert('From the child component: ', 'Hello from Button');