beforeNavigate isn't called for ReactRouterV6
See original GitHub issueIs there an existing issue for this?
- I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues
- I have reviewed the documentation https://docs.sentry.io/
- I am using the latest SDK release https://github.com/getsentry/sentry-javascript/releases
How do you use Sentry?
Sentry Saas (sentry.io)
Which package are you using?
SDK Version
7.11.0
Framework Version
React 17.0.2
Link to Sentry event
No response
Steps to Reproduce
- Setup sentry instrumentation with ReactRouterV6 according to the docs
- Implement some dummy function for “beforeNavigate” on BrowserTracing options
integrations: [
new BrowserTracing({
routingInstrumentation: Sentry.reactRouterV6Instrumentation(
useEffect,
useLocation,
useNavigationType,
createRoutesFromChildren,
matchRoutes,
),
beforeNavigate: (ctx) => {
console.log(ctx);
return ctx;
},
}),
],
- Go into the browser and navigate across different routes
Expected Result
console would print the ctx of each navigation
Actual Result
Except pageload - initial navigation , nothing happens.
Also tried to blend into “matchRoutes” function using hoisting. Also tried to capture the event in “beforeSend” Seems like the events doesn’t go trough there. Trying to enrich the events with the route context.
Issue Analytics
- State:
- Created a year ago
- Comments:15 (7 by maintainers)
Top Results From Across the Web
React Router v6 useNavigate() doesn't navigate if ...
I just read in React Router Dom Docs v6 this solution: ... After replacing the url, manually calling navigate(0) will refresh the page...
Read more >Navigate v6.6.1
A <Navigate> element changes the current location when it is rendered. It's a component wrapper around useNavigate , and accepts all the same...
Read more >Navigation in React App using React Router (v6)
Guide on different ways of routing in React using the React Router. Includes nested routing, authenticated routing, accessing URL and query parameters etc....
Read more >React Router v6
Although we bolted a few hooks onto v5 in 5.1, React Router v6 was ... Component { return ( <> {/* This route...
Read more >React Router V6 Tutorial - Routes, Redirecting, UseNavigate ...
Hey everyone, in this video I teach you all the new version of React Router Dom. I have an old video teaching this...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Ah ok, was able to reproduce with https://stackblitz.com/edit/github-7tjxzc-gabqis?file=src/App.tsx. Will take a look!
We stuck with the same issue. Hope the solution or fix will be found soon.