@xiiicool

Как победить ошибку в react hook form?

использую react hook form 7.4
ts 4.9.5
в методе setValue выдаёт ошибку Type instantiation is excessively deep and possibly infinite.
type FormValues = {
  country: CountryModel | null;
  carrier: CarrierModel | null;
  currency: CurrencyModel | null;
  bankNum: string;
};

export const Add = () => {
  const { activeRowCarriersTable } = useContext<{
    activeRowCarriersTable: CarrierModel | undefined;
  }>(Context);
  const methods = useForm<FormValues>({
    defaultValues: {
      country: null,
      carrier: null,
      currency: null,
      bankNum: '',
    },
  });

  useEffect(() => {
    setCountryActiveRow(activeRowCarriersTable?.country || null);
    methods.setValue('carrier', activeRowCarriersTable);
    // methods.setValue('currency', activeRowCarriersTable?.currency as null);
    // eslint-disable-next-line react-hooks/exhaustive-deps
  }, [activeRowCarriersTable]);


TS2589: Type instantiation is excessively deep and possibly infinite.
    64 |   useEffect(() => {
    65 |     setCountryActiveRow(activeRowCarriersTable?.country || null);
  > 66 |     methods.setValue('carrier', activeRowCarriersTable);
       |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    67 |     // methods.setValue('currency', activeRowCarriersTable?.currency as null);
    68 |     // eslint-disable-next-line react-hooks/exhaustive-deps
    69 |   }, [activeRowCarriersTable]);
  • Вопрос задан
  • 156 просмотров
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Похожие вопросы