🐛(rect) fix rhf select example
clearing the select trigger a infinit loop
This commit is contained in:
5
.changeset/fifty-jokes-dress.md
Normal file
5
.changeset/fifty-jokes-dress.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@openfun/cunningham-react": patch
|
||||
---
|
||||
|
||||
Fix Select usage with react hook form
|
||||
@@ -4,7 +4,7 @@ import { Select } from ":/components/Forms/Select/index";
|
||||
import { SelectProps } from ":/components/Forms/Select/mono";
|
||||
|
||||
export const RhfSelect = (props: SelectProps & { name: string }) => {
|
||||
const { control } = useFormContext();
|
||||
const { control, setValue } = useFormContext();
|
||||
return (
|
||||
<Controller
|
||||
control={control}
|
||||
@@ -16,7 +16,7 @@ export const RhfSelect = (props: SelectProps & { name: string }) => {
|
||||
state={fieldState.error ? "error" : "default"}
|
||||
text={fieldState.error?.message}
|
||||
onBlur={field.onBlur}
|
||||
onChange={field.onChange}
|
||||
onChange={(e) => setValue(field.name, e.target.value)}
|
||||
value={field.value}
|
||||
/>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user