I created an array of properties for a routes
const routes: RouteProps[] = [
{
path: '/',
exact: true,
component: Main,
},
];
and created a separate routing switch component
const Routes: FunctionComponent = (): JSX.Element => {
return (
<Switch>
{
routes.map((props: RouteProps, idx: number) => <Router key={idx} {...props} />)
}
</Switch>
);
};
But I get an error:
Error:(10, 57) TS2769: No overload matches this call.
Overload 1 of 2, '(props: Readonly): Router', gave the following error.
Property 'history' is missing in type '{ location?: Location | undefined; component?: ComponentClass, any> | FunctionComponent> | ComponentClass<...> | FunctionComponent<...> | undefined; ... 6 more ...; key: number; }' but required in type 'Readonly'.
Overload 2 of 2, '(props: RouterProps, context?: any): Router', gave the following error.
Property 'history' is missing in type '{ location?: Location | undefined; component?: ComponentClass, any> | FunctionComponent> | ComponentClass<...> | FunctionComponent<...> | undefined; ... 6 more ...; key: number; }' but required in type 'Readonly'.