Adding hooks with multiple routes
See original GitHub issueHello. Fantastic work with Navigo! I am able to get hooks working when adding a route. This may be a very simple matter of understanding Javascript, but I am unable to get the hooks working with multiple routes as in the Demo Basic code.
Is this possible? If so, where would I place the hooks objects when working with multiple routes? Thank you.
Hooks when adding a single route:
router.on(
"home",
function () {
console.log("home");
},
{
before: function (done, params) {
console.log("before");
done();
}
}
);
Hooks when adding multiple routes at once?
router.on({
'home': function () {
console.log("home")
},
'page1': function () {
console.log("page1");
}
});
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
How to use react context hook with multiple routes?
I'm working on a Chat Application and i wanted to store the information of the logged user so I used useContext hook for...
Read more >How React Hooks can replace React Router - LogRocket Blog
Looking for an alternative form of routing in your React projects? Read more to find out how React Hooks can replace React Router....
Read more >React Router's useRoutes hook - DEV Community
When creating multi-paged apps with React or any other library/framework, a package to handle routing is always used.
Read more >A Complete Beginner's Guide to React Router (Including ...
Then, add it where we want to render the content. The Route component has several properties. But here, we just need path and...
Read more >Routing in React - Pragim Tech
what is Routing in React, how to use exact in Routing in React, ... have specified the Navigation URL's and we have added...
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
Hi.
Thanks for your hard work. I rly like this router. Seeing this by searching for another Problem and i think i got an solution? See the folowing example:
by the way, with this snippet i set a css class which underlines the current link. Maybe someone can use this snippet.
That could be done much more efficient, but anyway … you can see the syntax 😃
Extending on solution given by @op3d
Below is the same solution code, but with the params and queryString available: