Реактивный маршрутизатор с рутером и родовым кодом TypeScript - PullRequest
0 голосов
/ 21 января 2019

Код

import { RouteComponentProps, withRouter } from "react-router";
import * as React from "react";

interface Props<T> {
    foo: T;
    children: (foo: T) => React.ReactNode;
}

function Component<T>(props: Props<T> & RouteComponentProps) {
    return props.children(props.foo);
}

export const Bar = withRouter(Component);

Error

TS2345: Argument of type '<T>(props: Props<T> & RouteComponentProps<{}, StaticContext, any>) => ReactNode' is not assignable to parameter of type 'ComponentType<Props<{}> & RouteComponentProps<{}, StaticContext, any>>'.
  Type '<T>(props: Props<T> & RouteComponentProps<{}, StaticContext, any>) => ReactNode' is not assignable to type 'FunctionComponent<Props<{}> & RouteComponentProps<{}, StaticContext, any>>'.
    Type 'ReactNode' is not assignable to type 'ReactElement<any> | null'.
      Type 'undefined' is not assignable to type 'ReactElement<any> | null'.

Как добавить свойства маршрутизатора в компонент, сохраняющий T?

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...