score:1

I had the same issue, and the idea from @goediaz works fine to me, the only diference was I'm working with funcional components.

const MyFunciont: React.FC<IGlobalState> = (_RouteComponentProps, props) = {
//here your code

return (
    //html code
    )
}

score:5

So the problem is being caused by the Props which are marked as required in the RouteComponentProps class.

As you workaround you need to export your class as any, it will export your class without any type.

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

interface Props extends RouteComponentProps { }

class ChildImpl extends React.Component<Props> {
    render() {
        return (
            <div>

            </div>
        )
    }
 }
const Child = withRouter(ChildImpl as any);//Note: It is a workaround not an actual solution
export default Child;

And then in your parent:

import * as React from 'react'
import Child from './Child';
export default class Parent extends React.Component {
    render() {
        return (
            <div>
                <Child />
             </div>
        )
    }
}

No Props will be required to pass.


Related Query

More Query from same tag