ReactJS TS, Property 'match' does not exist on type 'Readonly<{children?:ReactNode}> & Readonly<MyProps>'
This is an open issue in type definition. https://github.com/DefinitelyTyped/DefinitelyTyped/issues/17355
Workaround
import { RouteProps } from 'react-router';
import React from 'react';
interface MyProps {
api: Api
}
interface MyState {
someString: string,
loading: boolean
}
class MyComponent extends React.Component<Props & RouteProps, State> // Pay attention here.
{
// your code...
}
ref: https://github.com/DefinitelyTyped/DefinitelyTyped/issues/17355#issuecomment-336022780
Try to add RouteComponentProps inteface to your props. Change:
export class MyComponent extends React.Component<MyProps, MyState> {
to
export class MyComponent extends React.Component<MyProps & RouteComponentProps, MyState> {
I experienced a similar issue and found the least type breaking fix is to locally cast the params as any.
someString: (this.props.match.params as any).someString