Skip to content

Instantly share code, notes, and snippets.

@louisrli
Last active May 21, 2020 14:09
Show Gist options
  • Save louisrli/13f52ac417a1eeeae483f48e7317e031 to your computer and use it in GitHub Desktop.
Save louisrli/13f52ac417a1eeeae483f48e7317e031 to your computer and use it in GitHub Desktop.
Props and State: Teach each other

React Props and State

Learning Goal

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

Requirements

Person 1: Props

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

Person 2: State

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.

Timeline

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

@louisrli
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment