UNPKG

use-wizard

Version:

A dead-easy-to-use light-weight react hook to handle multi-paths wizards (and simple wizards too) and navigate into them.

14 lines (8 loc) 422 B
import {TStep} from "../types/TStep"; export {goToStep}; const goToStep = (args: {setHistory: Function, setPoppedHistory: Function}) => (step: unknown) => { if(typeof step !== "string" && typeof step !== "number") return console.log("Wizard warning: step to go to invalid type, it should be a string or a number"); args.setPoppedHistory([]); args.setHistory((ps: TStep[]) => [...ps, step]); return; }