react-router-cache-route icon indicating copy to clipboard operation
react-router-cache-route copied to clipboard

Property 'path' does not exist

Open ajakka opened this issue 4 years ago • 1 comments

react 17.0.1 react-router && react-router-dom 5.2.0

I have this code:

import CacheRoute, { CacheSwitch } from "react-router-cache-route";
...
<HashRouter>
        <CacheSwitch>
            <CacheRoute path="/story" component={StoryScreen} />
            <Route exact path="/" component={HomeScreen} />
        </CacheSwitch>
</HashRouter>

But when I run it it gives me:

TypeScript error in /Users/Abderrahim/story/src/App.tsx(30,25):
No overload matches this call.
  Overload 1 of 2, '(props: CacheRouteProps | Readonly<CacheRouteProps>): CacheRoute', gave the following error.
    Type '{ path: string; component: (props: any) => Element; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes<CacheRoute> & Readonly<CacheRouteProps> & Readonly<...>'.
      Property 'path' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<CacheRoute> & Readonly<CacheRouteProps> & Readonly<...>'.
  Overload 2 of 2, '(props: CacheRouteProps, context: any): CacheRoute', gave the following error.
    Type '{ path: string; component: (props: any) => Element; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes<CacheRoute> & Readonly<CacheRouteProps> & Readonly<...>'.
      Property 'path' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<CacheRoute> & Readonly<CacheRouteProps> & Readonly<...>'.  TS2769

    28 |         <HashRouter>
    29 |           <CacheSwitch>
  > 30 |             <CacheRoute path="/story" component={BookScreen} />
       |                         ^
    31 |             <Route exact path="/" component={HomeScreen} />

ajakka avatar Jun 03 '21 10:06 ajakka

There seems to be a problem with the writing of the type definition file. Try to temporarily ignore it with @ts-ignore, which should not affect the cache function.

CJY0208 avatar Jun 09 '21 03:06 CJY0208