Menu

Derived Values & Component State Lifting

Derived Values & Component State Lifting

A. Derived/computed values are new pieces of information calculated from existing data, instead of being stored separately. In AdminPage, values like total reviews, average rating, and low-rating count aren't stored as their own state — they're calculated live from the REVIEWS list every time the component renders, keeping the data always accurate without duplication.

B. Component state lifting happens when a piece of state is kept in a parent component so multiple children can share and affect it. Here, the selected state lives inside CustomerPage, not inside ProductCard — so ProductCard calls onSelect to update the parent's state, and ReviewModal calls onClose to reset it, letting both components work together through one shared source of truth.