Menu

useState Hook & Conditional Rendering

useState Hook & Conditional Rendering

A. The useState hook lets a functional component hold and update its own data over time. This project relies on it heavily — rating and hover inside StarInput, text and submitted inside ReviewModal, drawerOpen inside Navbar for the mobile menu, filter inside AdminPage for the rating filter, and selected inside CustomerPage to track which product's modal is open.

B. Conditional rendering means showing different UI depending on the current state. In this project, the review modal only appears when a product is selected, the modal itself switches between the review form and a "submitted" confirmation view, the "Out of stock" label only shows when quantity is zero, the mobile drawer slides in only when drawerOpen is true, and the admin table shows a "No reviews match this filter" message when the filtered list is empty.