Skip to content

Problem redirecting to another module with react-router-dom #2822

Closed Answered by yasiinakbulut58
ahmetartana asked this question in Q&A
Discussion options

You must be logged in to vote

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

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by ahmetartana
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants