Implement a hook useStep(totalSteps, initialStep = 0) that manages the state of a step counter for a multi-step process.
The hook should:
next step, prev step, reset to initial step, and setStep(n) to jump to a specific step.isFirst and isLast to check if the current step is at the boundaries.Example
const stepper = useStep(5); stepper.next(); console.log(stepper.step); // 1 stepper.setStep(4); console.log(stepper.isLast()); // true
JavaScript Function
No test results yet
Click "Run" to execute tests