event.preventDefault in react-router-dom is not working in Chrome and Firefox
See original GitHub issuefound this issue recently, the a tag generated by Link component will sometime refresh the whole page when the link is clicked, and it’s not 100% happened, sometimes it works as expected, but sometimes it refreshes the whole page
I think this issue most likely is related to browser, but just want to know anyone facing the same issue, and if so, is there anyway to solve it?
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (2 by maintainers)
Top Results From Across the Web
event.preventDefault in react-router-dom is not working in ...
found this issue recently, the a tag generated by Link component will sometime refresh the whole page when the link is clicked, and...
Read more >preventDefault won't work on Firefox - Stack Overflow
Your problem seems to be syntax errors and misnamed parameters. ... This always works: Firefox needs the "event handler", Chrome doesn't.
Read more >Window: beforeunload event - Web APIs | MDN
The HTML specification states that authors should use the Event.preventDefault() method instead of using Event.returnValue to prompt the user.
Read more >How To Handle DOM and Window Events with React
By responding to events with event handlers, you can create dynamic ... To stop an event, call the preventDefault action on the event....
Read more >Modern client-side routing: the Navigation API
Chrome, for example, activates its native loading indicator, and allows the user to interact with the stop button. (This doesn't currently happen when...
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 Free
Top 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

@kambing86 This should be fixed via #6711 in the next release.
@timdorr not sure should
react-routercatchs the error, but I don’t think is a common issue, just FYI