Props
Props are inputs to a component. The word means properties.
They flow down from parent to child. A child cannot change its props. It can only read them.
Passing props looks like HTML attributes
Destructure for clarity
Most React code pulls names out of props in the argument list.
Any value can be a prop
Strings, numbers, booleans, arrays, objects, even functions.
Booleans can be shorthand. loggedIn is true if you write the name alone.
Default values
If a parent forgets a prop, give a fallback.
Props are read-only
Never assign to a prop. That would surprise the parent, who owns the data.
To change what you see, the parent must pass a new value, often from state.
Spread when you forward many props
Put your own className first, then think about whether a spread should be allowed to override it.
Tip: Name props after what they mean, not after the widget. title is better than text1.
Test yourself
Three quick questions made just for this lesson. Earn 10 XP per correct answer.