我在准确上出现错误:
<Switch>
<Route path="/a" exact component={() => <div>Home page</div>}</Route>
</Switch>
错误是:
Type '{ path: string; exact: true; component: () => Element; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes<Component<RouteProps, any, any>> & Readonly<RouteProps> & Readonly<...>'.
Property 'exact' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<Component<RouteProps, any, any>> & Readonly<RouteProps> & Readonly<...>'.ts(2322)
那么,这是怎么回事?
我正在从react-router-dom
导入组件。并且也有@types
。在index.d.ts中,RouteProps没有exact?: Boolean
。