收到错误:void' 无法分配给 React js 中的类型 'FC<IPickWinnerProps>'

tak*_*aks 3 reactjs

当我运行我的网站时,我在 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
Run Code Online (Sandbox Code Playgroud)

在这里,我已经上传了我的整个代码,任何人都可以帮助我为什么我会收到此错误吗?

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);
}
Run Code Online (Sandbox Code Playgroud)

fel*_*osh 5

您忘记返回某些组件,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>; // <---
};

Run Code Online (Sandbox Code Playgroud)