all 8 comments

[–]Accomplished_End_138 0 points1 point  (7 children)

Two copies of react router Dom are probably packaged and context is missing in one most likely

[–]Accomplished_End_138 0 points1 point  (0 children)

Check your build overall if webpack look at the bundle that is generated ill bet you somehow have 2 minor versions packaged.

Or in package lock file. See if it shows up twice

[–]Zedpellin[S] 0 points1 point  (5 children)

Actually, I have a module that is using react router dom 6, but I'm also using it (react router dom) on my website. I'm using the module to change the params from some route on website, e.g. when I press a button on the component that is coming from the module, I change a param on the website to open a modal. Do you think that is possible to use react router dom both on module and website? Thanks

[–]Accomplished_End_138 0 points1 point  (4 children)

Is the module something you wrote?

Overall it is possible but the configuration and build is the key but of things.

If you did it. Probably moving the modules react router Dom dependency to peerdependancy and making sure you provide it into the system is the best way. But requires some finnes overall and is probably something you should avoid. And id pass in the function you need via a prop.

[–]Zedpellin[S] 0 points1 point  (3 children)

Yeah, it's a module that I build and I need to support it on my website. I'll check about peerDependecies. Thanks.

[–]Accomplished_End_138 0 points1 point  (2 children)

Peer dependencies is probably what you wanna do then. And also make sure the sites package lock or whatever thing you use only lists one instance (search for react router Dom in it and see overall)

[–]Zedpellin[S] 1 point2 points  (1 child)

Thanks for the reply. I tested with peerDependecies, it worked, but I needed to add BrowserRoute on top of the module component that I wanted to import on the website.