Welcome to part-7 of the series. You can find part-6 here. We will first learn about passing data from children to parent component.
Methods as props
In react we generally pass data(or props) from parent component to child component. But if we want to pass props from Child to Parent component, we need to pass methods.
We will create a class based component ParentComponent inside components folder. It have a local state of parentName and a greetParent(), which will show an alert containing this state.
In the render part, we are simply calling a ChildComponent.