core icon indicating copy to clipboard operation
core copied to clipboard

Update react-router-dom dependency and compatibility v7

Open douglaszaltron opened this issue 1 year ago • 11 comments

Clear and concise description of the problem

About bridge/bridge-react package

Current Situation

  • Current dependency: "react-router-dom": ">=4"
  • react-router-dom is migrating to version 7
  • Package will be renamed to just react-router

Issue Description

react-router-dom is moving towards version 7 and will be changing its package name to just react-router. Given this upcoming change, do we have any plans or movement to support the new react-router package in bridge?

Questions

  • Is there a migration plan?
  • Should we start accepting both packages?
  • What's the compatibility impact?

Suggested solution

Although I understand that the transition to v7 was designed to be to be non-breaking, I have concerns about the package name. I believe we should support both versions.

The migration to just react-router is inevitable. 🤔

Alternative

No response

Additional context

No response

Validations

  • [X] Read the Contributing Guidelines.
  • [X] Check that there isn't already an issue that request the same feature to avoid creating a duplicate.

douglaszaltron avatar Nov 22 '24 12:11 douglaszaltron

Thanks for your feedback, we are aware of this issue too, we do need to be compatible with this change in the future, we will adjust the implementation of bridge to be compatible with react-router-dom v7, thank you again~

danpeen avatar Nov 27 '24 14:11 danpeen

Was trying to implement react-bridge with react-router v7 no wonder why it keep throwing error: Uncaught (in promise) TypeError: Cannot set properties of undefined (setting 'usingClientEntryPoint') Lucky enough I found this issue

makara4code avatar Dec 27 '24 05:12 makara4code

@ScriptedAlchemy Do we have something in mind regarding how we expect the behavior for v7 with the name react-router or react-router-dom with v7? I've noticed that some projects are already migrating to react-router. react-router-dom 6 is currently full of warnings, which is pretty annoying. :(

douglaszaltron avatar Feb 08 '25 03:02 douglaszaltron

Another point for the bridge is the creation of a plugin to make it compatible with @tanstack/react-router, which has also been gaining attention and is becoming quite interesting.

@jherr @zackarychapple

douglaszaltron avatar Feb 08 '25 03:02 douglaszaltron

Facing the same issue with bridge :( Any update on this ?

Error : ESModulesLinkingError: export 'useLocation' (imported as 'ReactRouterDOM') was not found in 'react-router-dom' (possible exports: BrowserRouter, RouterProvider)

Seems like the naming is still "react-router-dom"

Sanch0ous avatar Feb 10 '25 14:02 Sanch0ous

I believe this is already being resolved by @danpeen. Checking now

zackarychapple avatar Feb 10 '25 14:02 zackarychapple

Sorry, it is not yet compatible with v7. Tomorrow I will try to solve this problem as soon as possible.

danpeen avatar Feb 10 '25 15:02 danpeen

In this context, it would be great if the router dependency could be made optional. Currently, even if a remote does not require a router, a router dependency still needs to be added.

pstrh avatar Feb 10 '25 16:02 pstrh

Hello @pstrh , Yes, this is indeed a known issue that we need to address. I believe we can solve this problem along the way in this issue.

danpeen avatar Feb 11 '25 03:02 danpeen

Hi, any update regarding this issue ?

Sanch0ous avatar Feb 25 '25 13:02 Sanch0ous

@tannerlinsley and @danpeen It would be great to integrate TanStack Router with the bridge-react from module-federation. This way, we could manage the routing of micro-frontend applications using TanStack as well. Perhaps a collaboration in the design phase could be key to developing a functional version.

douglaszaltron avatar Mar 06 '25 15:03 douglaszaltron

Stale issue message

github-actions[bot] avatar May 05 '25 15:05 github-actions[bot]

Hi! Is this still planned to be fixed?

My setup is:

"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-router": "^7.6.0",

When I use createRemoteComponent, I get the same error @Sanch0ous mentioned:

ESModulesLinkingError: export 'useLocation' (imported as 'ReactRouterDOM') was not found in 'react-router-dom' (possible exports: BrowserRouter, RouterProvider)

And when I consume the remote component via createBridgeComponent exported '@module-federation/bridge-react/v18', as seen in this example, the app builds correctly, but TypeScript gets crazy:

Argument of type 'Promise<typeof import(".../@mf-types/remote/export-app")>' is not assignable to parameter of type 'Omit<ProviderFnParams<any>, "createRoot">'.
  Property 'rootComponent' is missing in type 'Promise<typeof import(".../@mf-types/remote/export-app")>' but required in type 'Omit<ProviderFnParams<any>, "createRoot">'.

Happy to create a new issue, if helpful.

Is the best solution for now to downgrade to react-router 6?

MarioC3 avatar May 17 '25 04:05 MarioC3

Hi, any progress ? We are still not able to use the bridge along with react-router v7

Sanch0ous avatar Jul 11 '25 08:07 Sanch0ous

Just found a solution. Just put in your package.json : "react-router": "xxxxx", "react-router-dom": "xxxxx"

Use the first one as you used to in your components, and the second one will be used by the bridge.

Sanch0ous avatar Jul 16 '25 09:07 Sanch0ous

@douglaszaltron @Sanch0ous Hello, We are very sorry for the late supporting for the react-router v7 in mf react-bridge. Now I think we have implemented a version that supports react-router v7. Could you try this version: @module-federation/bridge-react@0.0.0-feat-support-bridge-react-router-v7-20251015110202 to test if it works properly under react-router v7?

Additionally, to support the @tanstack/react-router project, we have set optional peerDependency for react-router-dom in this version. For consumers of the @tanstack/react-router project, they can manually pass basepath as a prop to the producer project to register the basepath in @tanstack/react-router.

danpeen avatar Oct 15 '25 11:10 danpeen

Stale issue message

github-actions[bot] avatar Dec 14 '25 15:12 github-actions[bot]