Skip to content
Justice Tech School

Lifting State Up

When two components need the same data, move the state to their closest common parent and pass it down with props and callbacks.

Example
function Parent() {
  const [text, setText] = useState('');
  return (
    <>
      <Input value={text} onChange={setText} />
      <Preview text={text} />
    </>
  );
}

Exercise

Where should shared state live?

The common 

Quiz Test

Where does shared state go?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.