Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't resolve 'react-router-dom' #366

Closed
lukasoppermann opened this issue Jun 20, 2022 · 7 comments
Closed

Can't resolve 'react-router-dom' #366

lukasoppermann opened this issue Jun 20, 2022 · 7 comments
Labels
help wanted Extra attention is needed

Comments

@lukasoppermann
Copy link

Hey,

I am getting the following error with Next.js@12, react@18 and beautiful-react-hooks@3.2.3

Header.tsx has the following import statement:

import { useWindowScroll, useThrottledCallback } from 'beautiful-react-hooks'; 

Please let me know what other info I can provide. I don't know what I am doing wrong here.

error - ./node_modules/beautiful-react-hooks/esm/useQueryParam.js:1:0
Module not found: Can't resolve 'react-router-dom'

Import trace for requested module:
./node_modules/beautiful-react-hooks/esm/index.js
./components/Header/Header.tsx
./pages/_app.tsx
@antonioru
Copy link
Owner

Hey,

I am getting the following error with Next.js@12, react@18 and beautiful-react-hooks@3.2.3

Header.tsx has the following import statement:

import { useWindowScroll, useThrottledCallback } from 'beautiful-react-hooks'; 

Please let me know what other info I can provide. I don't know what I am doing wrong here.

error - ./node_modules/beautiful-react-hooks/esm/useQueryParam.js:1:0
Module not found: Can't resolve 'react-router-dom'

Import trace for requested module:
./node_modules/beautiful-react-hooks/esm/index.js
./components/Header/Header.tsx
./pages/_app.tsx

Hi @lukasoppermann, thanks for opening this issue but looks like you're importing the entire library from index.ts and therefore importing useQueryParam which relies on react-router-dom.

You should import only hooks that you're using, follow the documentation examples

@antonioru antonioru added the help wanted Extra attention is needed label Jun 20, 2022
@antonioru
Copy link
Owner

@lukasoppermann please close the issue if it's solved ;)

@lukasoppermann
Copy link
Author

Did this change "recently"? Anyway, that of course helped. Thank you very much.

@antonioru
Copy link
Owner

Did this change "recently"? Anyway, that of course helped. Thank you very much.

mh, yes and no... the index.ts is there since the first releases but I've recently introduced hooks that are in fact relying on third parties, hence the issue. I had to fix the documentation to encourage importing single imports, that's correct

I will probably be deprecating the index file soon as it causes more troubles than anything

@wouterds
Copy link

wouterds commented Jul 6, 2022

This causes issues for people using this lib on platforms like react-native. While it's true it can be fixed by importing each hook separately from their own file it is an inconvenient breaking change and required us to fix quite a few components.

@robinclaes
Copy link

+1, not usable on React native at the moment.

@wouterds
Copy link

wouterds commented Sep 12, 2022

Don't think they'll be rolling back though. Can still be used by changing your imports, but still, annoying breaking change.

-import { usePreviousValue } from 'beautiful-react-hooks'
+import usePreviousValue from 'beautiful-react-hooks/usePreviousValue'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

4 participants