Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | 623x 623x 634x | import { useFormContext, Controller } from "react-hook-form";
import GiveSwitch, { SwitchProps } from "../../Switch/GiveSwitch";
export type HFGiveSwitchProps = SwitchProps & {
name: string;
};
export default function HFGiveSwitch({ name, ...props }: HFGiveSwitchProps) {
const { control } = useFormContext();
return (
<Controller
name={name}
control={control}
render={({ field: { ref, value, ...rest } }) => (
<GiveSwitch
inputRef={ref}
{...rest}
checked={Boolean(value)}
{...props}
/>
)}
/>
);
}
|