import React, { FC, useEffect, useState } from 'react' import { FieldValues, Controller, Control } from 'react-hook-form'; import { useFetchWithAuth } from '../hooks/useFetchWithAuth'; interface Props { entity: string, control: Control } export const Manytoone: FC = ({entity, control }) => { const [data, setData] = useState([{id:0,nombre:'Select one'}]); useEffect(() => { async function fetchData() { try { const { data, error } = await useFetchWithAuth(entity.toLowerCase()); setData(data); } catch (trace) { console.error(trace); } } fetchData(); }, [entity]); return ( <> ( )} name={entity} control={control} /> ) }