TypeScript 3: JSX element type 'Component' does not have any construct or call signatures. [2604]

后端 未结 5 742
挽巷
挽巷 2021-02-07 10:06

I\'m trying to pass a variable of type React.Component (or React.FunctionComponent) into a Route, like this:

import React from \'react\';
import { Route } from \         


        
5条回答
  •  梦如初夏
    2021-02-07 10:11

    I have encountered this a couple of times. Try these:

    1. Type your PrivateRoute as React.FC
    2. Type your incoming component as React.ElementType

    The ultimate truth about React types comes from the docs

    Edit: React.ReactType (deprecated) -> React.ElementType

提交回复
热议问题