hookrouter icon indicating copy to clipboard operation
hookrouter copied to clipboard

useRoutes is not a function

Open avkonst opened this issue 6 years ago • 6 comments
trafficstars

This is likely not hookrouter issue, but maybe somebody could give me an insight how to fix it.

I use hookrouter in production and recently trapped a crash. The error report says: 'TypeError: undefined is not a function' and call stack points to useRoutes function.

image

User's browser is Chrome, version | 41.0.2272 (a bit old, but caniuse reports 41 version supports the things I am using). User's OS is Linux.

I use react-scripts build to build the production version. Could you please give me a hint where to look at to fix it?

avkonst avatar Aug 25 '19 23:08 avkonst

You need to require useRoutes from router.js

przemo-hemmersbach avatar Sep 05 '19 08:09 przemo-hemmersbach

This screenshot is from the source map prepared by sentry errors collector. My app is bundled by react-scripts build and surely I include hookrouter. The user's browser is quite old but I am not sure why it fails on useroutes as it is not the first component in the app.

avkonst avatar Sep 05 '19 09:09 avkonst

I think useRoutes is separate import.

przemo-hemmersbach avatar Sep 05 '19 09:09 przemo-hemmersbach

I use typescript. It would not compile if an identifier is unknown. It certainly knows what useroutes is at compile time.

I guess this issue is not solvable. As I don't have enough information, can not reproduce it and do not know a user to contact who reproduced it.

On Thu, 5 Sep 2019, 21:24 przemo-hemmersbach, [email protected] wrote:

I think useRoutes is separate import.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Paratron/hookrouter/issues/81?email_source=notifications&email_token=AA6JSVPAZSEMEJ2J2AZNUBLQIDF3BA5CNFSM4IPKQUS2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD56OQAQ#issuecomment-528279554, or mute the thread https://github.com/notifications/unsubscribe-auth/AA6JSVJXYV3FL35EFY4X6SDQIDF3BANCNFSM4IPKQUSQ .

avkonst avatar Sep 05 '19 09:09 avkonst

I had a similiar error before in a production build. My reason was that I forgot to upload one of the bundle files to my webserver and its contents were missing during runtime.

Paratron avatar Sep 05 '19 11:09 Paratron

With React 17.0.0, Typescript 3.9.9 I have the same issue. It does not really matter the react version though as I tried different ones.

image

Deviad avatar Feb 14 '21 19:02 Deviad