diff --git a/src/index.tsx b/src/index.tsx index 6786927..c673cb8 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -36,9 +36,9 @@ const Switch = React.forwardRef((props, ref) => React.useEffect(() => { const { autoFocus, disabled } = props; if (autoFocus && !disabled) { - focus(); + (mergedRef.current as any).focus(); } - }, [props.autoFocus, props.disabled]); + }, [props.autoFocus]); React.useEffect(() => { if ('checked' in props) {