[英]is not assignable to parameter of type [React]
I have problem in react I wrote enum type我在反应中遇到问题我写了枚举类型
enum.ts枚举
export enum DivingType {
FreeDiving = "FreeDiving",
ScubaDiving = "ScubaDiving",
}
and my home screen has graphql hooks我的主屏幕有 graphql 钩子
home.tsx主页.tsx
import { DivingType } from "..."
export const Home = () => {
const [divingType, setDivingType] = useState<DivingType>(DivingType.FreeDiving)
const [pageNumber, setPageNumber] = useState(1)
useMatchingList(divingType, pageNumber)
// --------------------[ Return ]--------------------
return ...
useMatchingList.tsx useMatchingList.tsx
interface IUseMatchingListProps {
divingType: DivingType
pageNumber: number
}
export const useMatchingList: React.FC<IUseMatchingListProps> = ({
divingType,
,
}) => {...}
and I have我有
Argument of type 'import("...").DivingType' is not assignable to parameter of type 'PropsWithChildren<IUseMatchingListProps>'
useMatchingList(divingType, pageNumber)
| ^
what is the matter ?有什么事 ? please help me !
请帮我 !
The FC
in React.FC
means "Functional Component". React.FC
的FC
的React.FC
是“功能组件”。 And a hook is not a component.一个钩子不是一个组件。 A custom hook is just a function that calls other hooks.
自定义钩子只是调用其他钩子的函数。 So it takes arguments just like any function would.
所以它就像任何函数一样需要参数。
That means your hooks should look more like this:这意味着你的钩子应该看起来更像这样:
export const useMatchingList = (divingType: DivingType, pageNumber: number) => {
// my hook implementation
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.