cf.completefrontend
Open lab My progress
THE REACT FIELD GUIDE

Sharing state between components

Lift state up to the closest common parent so two components stay in sync. Controlled and uncontrolled components, with live examples and an out-of-sync test.

By the end, you can
  • 01
    Lift state upMove state out of two components into their closest common parent, and pass it back down as props, so they can't disagree.
  • 02
    Tell controlled from uncontrolledSay whether a component or an input is driven by its own state or by props, and what each choice lets the parent do.
  • 03
    Pass handlers downLet a child change its parent's state by calling a function the parent passed it, like onOpen or onChange.
CompleteFrontend Clear concepts. Working examples.