当我运行我的网站时,我在React js中收到此错误
TypeScript error in /var/www/oxygen/allbadcards/client/src/Areas/Game/GamePlayBlack.tsx(29,14):
Type '({ onPickWinner, canPick, timeToPick, hasWinner, revealMode }: PropsWithChildren<IPickWinnerProps>) => void' is not assignable to type 'FC<IPickWinnerProps>'.
Type 'void' is not assignable to type 'ReactElement<any, string | ((props: any) => ReactElement<any, string | ... | (new (props: any) => Component<any, any, any>)> | null) | (new (props: any) => Component<any, any, any>)> | null'. TS2322
我在这里上传了我的完整代码,有人可以帮我为什么我会收到此错误吗?
GamePlayBlack.tsx
export interface IPickWinnerProps
{
children?: undefined;
canPick: boolean;
timeToPick: boolean;
revealMode: boolean;
hasWinner: boolean;
}
export const PickWinnerIdle: React.FC<IPickWinnerProps> = (
{
onPickWinner,
canPick,
timeToPick,
hasWinner,
revealMode
}
) =>
{
const gameData = useDataStore(GameDataStore);
const userData = useDataStore(UserDataStore);
const [pickWinnerLoading, setPickWinnerLoading] = useState(false);
setPickWinnerLoading(true);
}
答案 0 :(得分:0)
您忘记从PickWinnerIdle
返回某些组件,因此您的功能组件返回“ void”。
export const PickWinnerIdle: React.FC<IPickWinnerProps> = ({
onPickWinner,
canPick,
timeToPick,
hasWinner,
revealMode,
}) => {
const gameData = useDataStore(GameDataStore);
const userData = useDataStore(UserDataStore);
const [pickWinnerLoading, setPickWinnerLoading] = useState(false);
setPickWinnerLoading(true);
return <div>bla</div>; // <---
};