In my project, I have a component named Navbar that relies on the location object from history, which is defined in RouteComponentProps.
I attempted to include a custom prop in my component like this:
interface IProps{
title?: string
}
class Navbar extends React.Component<RouteComponentProps<{}> & IProps>{
}
Although this code does not throw an error, when I try to use it like this:
<Navbar title="My Custom Page Title" />
Typescript gives me the following error:
Type '{ title: string; }' is not assignable to type '(IntrinsicAttributes & IntrinsicClassAttributes
Initially, I tried this approach:
interface IProps extends RouteComponentProps{
title?: string
}
However, it also resulted in a typescript error.
I am uncertain about the correct way to extend or expand RouteComponentProps.