Проблема с React Router при использовании с машинописным текстом - PullRequest
1 голос
/ 25 мая 2020
• 1000 это вызывает проблемы с объявлением маршрута. Как только я правильно определил свойства в Show, объявление маршрута показывает ошибку в компоненте
<Route path="/companies/:id" exact={true}  component={ShowCompany} />
  Overload 1 of 2, '(props: Readonly<RouteProps>): Route<RouteProps>', gave the following error.
    Type '(props: RouteComponentProps<ShowParams, StaticContext, PoorMansUnknown>) => Element | undefined' is not assignable to type 'ComponentClass<any, any> | FunctionComponent<any> | ComponentClass<RouteComponentProps<any, StaticContext, PoorMansUnknown>, any> | FunctionComponent<...> | undefined'.
 Type 'Element | undefined' is not assignable to type 'ReactElement<any, any> | null'.
          Type 'undefined' is not assignable to type 'ReactElement<any, any> | null'.
  Overload 2 of 2, '(props: RouteProps, context?: any): Route<RouteProps>', gave the following error.
    Type '(props: RouteComponentProps<ShowParams, StaticContext, PoorMansUnknown>) => Element | undefined' is not assignable to type 'ComponentClass<any, any> | FunctionComponent<any> | ComponentClass<RouteComponentProps<any, StaticContext, PoorMansUnknown>, any> | FunctionComponent<...> | undefined'.
      Type '(props: RouteComponentProps<ShowParams, StaticContext, PoorMansUnknown>) => Element | undefined' is not assignable to type 'FunctionComponent<any>'.  TS2769

, что имеет смысл, поскольку он больше не может просто отображать компонент без объявления props

Как объявить тип props в маршрутах.

...