React props and state: notes from a Zerobase lecture
While taking Zerobase's React lecture "Rapid Progress React, Easy to Understand", I'm writing down the points I need to remember.
First, props are values that a parent component passes to a child component. In the lecture, I think a child component received props as props.(the passed name) and so on, and a value added in between without a set name was received as props.children.
Also, a child component can't change the value of the props it receives.
Next, state is a value that a component manages by itself. In JS, I think when a value changed and I wanted to re-render, I did it by calling the function again. In React, it seems you use the useState() function to change only the part you want, dynamically.
Finally, what props and state have in common is that a component renders when it gets a value through props, or when the state it manages changes.
- #React props and state notes