Build a grid where clicking a cell lights it up, and then the lit cells switch off one by one in the reverse order they were activated — last on, first off. The key is to record the order of activation in an array, and let a timer peel cells off the end of that array.
// A self-contained component. No props.
function App(): JSX.Element;
A grid of cells; click to light, then watch them unwind.
click 0, then 4, then 7 → cells 0, 4, 7 lit (order = [0, 4, 7])
timer ticks → 7 off, then 4 off, then 0 off (reverse / LIFO)
clicking an already-lit cell does nothing;
clicking while cells are unwinding just extends the order again.
order array of clicked indices; "lit" = index is in order.order is non-empty.