router.refresh() disables scroll restoration
Unanswered
American black bear posted this in #help-forum
American black bearOP
When I use router.back() it sends me back properly and I'm on the scroll position I was earlier.
However, when I use router.refresh() to refresh data updated in database and use router.back() it always sends me to the top of the previous page. Moreover I feel like it loses "cache" and loads a little longer after router.refresh().
Any idea of how to fix it?
However, when I use router.refresh() to refresh data updated in database and use router.back() it always sends me to the top of the previous page. Moreover I feel like it loses "cache" and loads a little longer after router.refresh().
Any idea of how to fix it?
9 Replies
American black bearOP
Can anyone help with this issue?
American black bearOP
Hey there, any solution for this one?
router.refresh() shouldn't be making you lose state
router.back() might be the issue tho
What exactly are you trying to achieve by chaining the two?
If its something like a form updating data and then going back to a page which shows the updated data, then all you need to do is basically use Router.push() to the previous page and do a router.refresh() right after that.
I personally do something like this:
router.replace("/dashboard/sales/customers");
router.refresh();@Clown What exactly are you trying to achieve by chaining the two?
American black bearOP
1. I scroll a page A to the bottom.
2. I go to a page B.
3. I do operation on database on page B and do router.refresh() to update all components using the new data.
4. I use router.back() to go to the page A and it works fine, but I’m not scrolled to the bottom like I was earlier.
However when I use router.back() without using router.refresh before it - it remembers scroll position.
2. I go to a page B.
3. I do operation on database on page B and do router.refresh() to update all components using the new data.
4. I use router.back() to go to the page A and it works fine, but I’m not scrolled to the bottom like I was earlier.
However when I use router.back() without using router.refresh before it - it remembers scroll position.
American black bearOP
Any idea?