diff --git a/src/helpers/useStableEventHendler.ts b/src/helpers/useStableEventHendler.ts index 9d94f14..295b099 100644 --- a/src/helpers/useStableEventHendler.ts +++ b/src/helpers/useStableEventHendler.ts @@ -1,18 +1,14 @@ import React from 'react'; -function error() { - throw new Error('Cannot call an event handler while rendering or after unmount.'); -} - export function useStableEventHandler void>( func: TFunc | undefined, ) { - const ref = React.useRef(error as any); + const ref = React.useRef(undefined); React.useEffect(() => { ref.current = func; return () => { - ref.current = error as any; + ref.current = undefined; }; }, [func]); diff --git a/src/stories/dialog/00_Base_controls.stories.tsx b/src/stories/dialog/00_Base_controls.stories.tsx index f71a417..6adf0ac 100644 --- a/src/stories/dialog/00_Base_controls.stories.tsx +++ b/src/stories/dialog/00_Base_controls.stories.tsx @@ -119,7 +119,7 @@ function DialogDemo({ ), }), - makeField('text'), + makeField('text', {autoFocus: true}), makeField('multi-text'), makeField('checkbox', {children: 'checkbox'}), makeField('tumbler', {labelLeft: 'Left label', labelRight: 'Right label'}),