useWizard.ts
1 import { useContext } from 'react' 2 import type { WizardContextValue } from './types.js' 3 import { WizardContext } from './WizardProvider.js' 4 5 export function useWizard< 6 T extends Record<string, unknown> = Record<string, unknown>, 7 >(): WizardContextValue<T> { 8 const context = useContext(WizardContext) as WizardContextValue<T> | null 9 if (!context) { 10 throw new Error('useWizard must be used within a WizardProvider') 11 } 12 return context 13 }