Skip to content
Rung

04/12

No. 04Easy10 min

Lifting State Up: The Mirror

Mission

Share data between sibling components by moving state to their closest common ancestor, so the UI always stays in sync.

Tasks

  1. 1

    Notice that InputComponent and DisplayComponent are siblings and cannot pass data to each other directly.

  2. 2

    Move the state and its setter from InputComponent up to App.

  3. 3

    Pass the value to DisplayComponent as a prop.

  4. 4

    Pass the update function to InputComponent so it can change the parent's state.

  5. 5

    Type in the input and check that the other component updates in real time.