DEV Community

Aisha A.
Aisha A.

Posted on

React props - A beginner's guide

This concept is when you're passing the data from the parent down to its direct children.

Image description

Take for example the image above where the App component has 2 children, the Modal component and the Form component. The App component has the following data.

Image description

How do we then pass the data down from App to Form component? That's when we're going to use "props". Props consists of all attributes that we pass the component to. What do I mean by that? Let's have a look at the example below:

Image description

Props is a shortened version for properties, quite similar to objects, each component have their own properties "IF" given any. If we were to convert the code above to a vanilla Javascript object, it will look like this:

Image description

Now let's have a look at our JSX code and identify the attributes.

Image description

As you've noticed, we have an attribute property and a value assigned to each attribute. Quite similar to how objects are.

Top comments (0)