Loading homepage
Implement a React hook that behaves like useState but exposes a default value whenever its raw state is null or undefined. Other falsy values, including false, 0, and an empty string, remain unchanged.
The default is derived during rendering. The returned setter still manages the underlying raw state.
Input: useDefault("Anonymous", null) Output: ["Anonymous", setValue]
Input: useDefault(10, 0) Output: [0, setValue]
Input: setValue("Ada"); then setValue(null) Output: Renders "Ada", then the default on subsequent updates.
useDefault(defaultValue, initialValue?) returns a rendered value and a React-compatible setter for raw nullable state.