Problem redirecting to another module with react-router-dom #2822
-
I want to redirect from one app to another app with Navigate but I get an issue like below. No routes matched location "/dashboard/home" (I already have "/dashboard/home" but in another mf module) This module is taken as an example : https://github.com/module-federation/module-federation-examples/tree/master/react-nested-routers Is it possible use react-router-dom navigate function? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Hi @ahmetartana, you can listen router changes on subApp and invoke a callback method. subApp hostApp also this stackoverflow link may be help; https://stackoverflow.com/questions/74165853/react-router-dom-v6-4-doesnt-allow-history-listen-prior-suggestions-deprecated |
Beta Was this translation helpful? Give feedback.
-
Thank you for your support @yasiinakbulut58 |
Beta Was this translation helpful? Give feedback.
Hi @ahmetartana,
you can listen router changes on subApp and invoke a callback method.
then you can use useNavigate() hooks on hostApp to update path. i hope below code helps your issue
subApp
router.subscribe((state) => { onNavigate(state); });
hostApp
mount({ ..., onNavigate: (state: RouteState) => { navigate(state.location.pathname); }, });
also this stackoverflow link may be help; https://stackoverflow.com/questions/74165853/react-router-dom-v6-4-doesnt-allow-history-listen-prior-suggestions-deprecated