Today, I learnt about React Props and these are the highlights I took away from what I learnt:
What do props help us accomplish?
What do props help us accomplish?
- Props helps us create components that are reusable.
- Props are like attributes for HTML elements
How do you pass a prop into a component?
- Props can passed into a component just like we pass attributes to HTML elements like <img src='yourimage' />
- For Props it will be <MyComponent title=' My Component' />
How do I receive props in a component?
function MyComponent(props) { console.log(props.title) return ( <h3> {props.title} </h3> ) }
P.S: This ia an oversimplified highlight of Props, if you need to know dive deeper check out the react docs on this topic