Tengo un problema al reaccionar. Escribí el tipo de enumeración.
enum.ts
export enum DivingType { FreeDiving = "FreeDiving", ScubaDiving = "ScubaDiving", }y mi pantalla de inicio tiene ganchos graphql
casa.tsx
import { DivingType } from "..." export const Home = () => { const [divingType, setDivingType] = useState<DivingType>(DivingType.FreeDiving) const [pageNumber, setPageNumber] = useState(1) useMatchingList(divingType, pageNumber) // --------------------[ Return ]-------------------- return ...usarMatchingList.tsx
interface IUseMatchingListProps { divingType: DivingType pageNumber: number } export const useMatchingList: React.FC<IUseMatchingListProps> = ({ divingType, , }) => {...}y yo tengo
Argument of type 'import("...").DivingType' is not assignable to parameter of type 'PropsWithChildren<IUseMatchingListProps>' useMatchingList(divingType, pageNumber) | ^Cuál es el problema ? por favor, ayúdame !
El FC en React.FC significa "Componente funcional". Y un gancho no es un componente. Un gancho personalizado es solo una función que llama a otros ganchos. Entonces toma argumentos como lo haría cualquier función.
Eso significa que tus ganchos deberían parecerse más a esto:
export const useMatchingList = (divingType: DivingType, pageNumber: number) => { // my hook implementation }