Using react-hook-from with react-swipeable-views

74 Views Asked by At

i'm trying to use react-hook-form with react-swipeable-views , but the state of the form resisted every time i switch between swipeable views, if anyone could help me i will be very thankful.

lien of stackblitz: https://stackblitz.com/edit/react-ts-mxyk44?file=Quiz.tsx

1

There are 1 best solutions below

1
Disco On

The stackblitz does not work, however I noticed that you do not use the render prop in your controllers. These are needed to get the value from the stored form.

RHF Controller doc

<Controller
  control={control}
  name="ReactDatepicker"
  render={({ field: { onChange, onBlur, value, ref } }) => (
    <ReactDatePicker onChange={onChange} onBlur={onBlur} selected={value} />
  )}
/>;