rhf
RHF Date Picker
React Hook Form wrapper cho DatePicker vá»›i há»— trợ validation và error handling tÃch hợp.
1. Import
Import the RHF Date Picker component from the design system.
import { RHFDatePicker } from "@/design-system/components/rhf";2. Props
RHF Date Picker component props.
| Prop | Type | Default |
|---|---|---|
| control | Control<T> | -- |
| name | Path<T> | -- |
| callback | (value: Date | undefined) => void | -- |
| label | string | React.ReactNode | -- |
| required | boolean | false |
| error | string | -- |
| className | string | -- |
3. Usages
Các pattern và cấu hình RHFDatePicker phổ biến.
import { RHFDatePicker } from "@/design-system/components/rhf";
import { useForm } from "react-hook-form";
function Example() {
const { control } = useForm({
defaultValues: {
date: undefined,
},
});
return (
<RHFDatePicker
control={control}
name="date"
label="Date"
placeholder="Pick a date"
/>
);
}