It’s not good practice to have a powerful tool like React and not take advantage of of it’s power.
In our Twitter Timeline that we created yesterday we hard coded all the information in ourselves, which defeats the purpose of using React, we could’ve done the same thing much faster with simple HTML. So let’s discuss how React allows for dynamic data.
When React refers to props it’s not
Instead it short for properties. Props are used to customize components when they are being created and give them different parameters.
One of the most important features of props is that they can be passed by a parent component to its child components. This allows us to create a component that can be customized with a new set of props every time we use it.
Props are passed to the component and are fixed throughout it’s lifecycle.
Let’s try to break this down with a real world example and try to clear up the concept of Props.
As a child my mom had a chore board and it had my name and my brothers name. Each week on Monday next to our name was a chore that we had to do.
In this example my mom is the parent component and my brother and I are the child components. The chore that was assigned to us is the prop. We had no say in it, and we couldn’t change it. We got it and had to do it.
Tomorrow we will see how to create a prop and use it in our components.