my-swiss-knife: - v1.9.9
    Preparing search index...

    Function useStepper

    • Custom hook to access Stepper context. Throws an error if used outside of Stepper provider.

      Returns StepperContextType

      StepperContextType - current step and navigation functions

      import { useStepper } from "./useStepper";

      const StepInfo = () => {
      const { currentStep } = useStepper();
      return <p>Current step: {currentStep}</p>;
      };
      export const useStepper = () => {
      const ctx = useContext(StepperContext)
      if (!ctx) throw new Error('useStepper must be used within a Stepper')
      return ctx
      }