Template didn't rerender when 2 routes render the same template
See original GitHub issueI have 2 route /
and /sell
linked to the same Template, but when I switch from one to the other, the template isn’t reloaded (so ReactiveVar aren’t updated).
This is my router:
FlowRouter.route('/', {
name: "dashboard",
action() {
console.log('go to buy');
BlazeLayout.render("layout", {nav: "publicNav", main: "dashboard"});
}
});
FlowRouter.route('/sell', {
name: "dashboard-sell",
action() {
console.log('go to sell');
BlazeLayout.render("layout", {nav: "publicNav", main: "dashboard"});
}
});
And the basic template onCreated function:
Template.dashboard.onCreated(function () {
console.log('Route name: ', FlowRouter.current().route.name)
})
So whem I call /
and I try to switch multiple times, I got:
go to buy
Route name: dashboard
go to sell
go to buy
go to sell
And When I start with /sell
(hard refresh) I got:
go to sell
Route name: dashboard-sell
go to buy
go to sell
How can I avoid that ? Or at least bind a function on this update event ?
Issue Analytics
- State:
- Created 7 years ago
- Comments:5
Top Results From Across the Web
iron:router will not re-render after route change with same ...
It does this by using the same template with different parameters. I can see the url change as I am switching routes, if...
Read more >Prevent re-rendering of template when transitioning to a route
I have a route and an associated template. The template provides a skeleton div into which I manually render content instead of using...
Read more >Ultimate React Router v6 Guide
If you want to render two different sections of content that both depend on the URL of the application then you need multiple...
Read more >How To Navigate Between Views with Vue Router
User interface (UI) frameworks like Vue.js render these pages and compone… ... In this example, if you were to visit a route of ......
Read more >How React Hooks can replace React Router - LogRocket Blog
Looking for an alternative form of routing in your React projects? ... Some things we didn't have issues with before have started causing ......
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
This is what I did to get around the issue. I reset BlazeLayout with a global trigger that fires for every route and clean out the DOM. Put this on top of your
routes.js
file.Another way to do it, use the
FlowRouter.watchPathChange()
function: