ReactJS Tutorial for Beginners -7

Image for post
Image for post
React

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.

Image for post
Image for post
ParentComponent

You can read the rest of the article from my site. Link for the same is below.

https://thewebdev.tech/react-basics-7

This completes part-7 of the series. You can find part-8 here.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store