At the end of this activity, you should understand what props and state are and know how to use them. How? You'll teach each other!
You'll be in pairs.
- Person 1: Responsible for props
- Person 2: Responsible for state
Create a component (your choice in making whatever you want) that has two required props and one optional prop. The optional prop should be optional because it has a default value.
- Use this component at least three times, once with the default prop unset
Create a component (your choice in making whatever you want) that has three state variables that are set to initial values.
Make an element which, on click, somehow modifies one of the state variables.
Bonus: Pass a state variable as a prop to another child component.
30 min, work in pairs but alone on the code. You can ask and chat. 20 min explain to each other, make sure everyone gets state and props. 20 min demo
https://repl.it/@templates/Create-React-App