Log React Router <Link/> clicks as actions?
See original GitHub issueI’m looking for a way to log clicks on <Link/>
components (from react-router@2.x.x) as actions. Currently a click throws this error: “Uncaught Invariant Violation: <Link>s rendered outside of a router context cannot navigate.”
Is there a way to do this already? I couldn’t find anything
The links addon is interesting, but a completely unrelated usecase.
Issue Analytics
- State:
- Created 7 years ago
- Comments:14 (7 by maintainers)
Top Results From Across the Web
Log React Router <Link/> clicks as actions? #485 - GitHub
I'm looking for a way to log clicks on <Link/> components (from react-router@2.x.x) as actions. Currently a click throws this error: "Uncaught ...
Read more >How to dispatch an action when clicking on Link when using ...
Eg: I click on Edit button -> Action is dispatched -> Store updated, {'state': 'edit-mode'} -> Proceed to redirect. Or do you have...
Read more >How to handle navigation in your app with React Router Link
In this article, we'll explore the navigation possibilities in a React app and we'll take a look at the React Router Link component....
Read more >Link v6.6.1 - React Router
A <Link> is an element that lets the user navigate to another page by clicking or tapping on it. In react-router-dom , a...
Read more >Navigation in React App using React Router (v6)
import { Routes, Route, NavLink as Link } from "react-router-dom" ... on certain user action, say on click of a button, react router...
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
Here’s the “correct” way to replace React-Router’s history functions with actions. This is in my
config.js
:I tried this, here’s how to do this:
First create a file called
rr.js
inside your Storybook config directory (.storybook
) with the following content:Then create another file called
webpack.config.js
and add following content: