Loading homepage
Create state whose updates pass through a mediator before being committed.
Input: const [count, setCount] = useMediatedState( next => Math.max(0, Math.min(10, next)), 0, ); setCount(20); Output: The next state is 10.
Input: const [value, setValue] = useMediatedState( (next, previous) => next < previous ? previous : next, 5, ); setValue(3); Output: The mediator rejects the decrease, leaving state at 5.
Implement the exported React hook in index.js or index.ts. Tests provide fixtures for the required behavior.