Loading homepage
Input: useStateWithReset(0); setState(5); reset(); Output: State starts at 0, becomes 5 after an update, and returns to 0 after reset.
Input: useStateWithReset(() => ({ name: "Ada" })); update the name; reset(); Output: Reset restores the original object reference without calling the initializer again.
Input: useStateWithReset(5); setState(100); then queue reset() and setState(previous => previous + 1) together Output: The next rendered state is 6.
useStateWithReset(initialState) returns [state, setState, reset]. initialState may be a value or a pure initializer. reset restores the resolved initial state of this mounted instance.