Lifting State Up and useReducer
Learn Lifting State Up and useReducer (Phase 4 · State and Event Handling (Essential), ReactJS) with worked examples, diagrams and interview questions. Free on JavaSchoolLab.
Sharing state between components • When two components need the same data, lift the state up to their closest common parent. The parent passes the value down as a prop and a setter (callback) down for changes. • Data flows down, events flow up ("inverse data flow").