question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Silently replacing a URL

See original GitHub issue

When calling Router.replace(), I’d like to update the URL without reloading the page (or call getInitialProps again).

When rendering on the server, we’re sometime fetching defaults parameters. Once the page reach the browser, we’d like to update the query to match the default parameters that were selected in order to ensure reloading/sharing the page will use the same parameters.

Allowing silent url change would allow us to skip server-side redirect to the final URL improving load time.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:10 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
vladkacommented, Oct 30, 2017

But shallow routing still calls render method on the page. And the second problem, that shallow routing is restricted only to the same page. My problem is, I need to do only something like “history.pushState({}, “page 2”, “mypath”);” - i want to stay on the same page (without rerendering, because it is to expensive), and solution with “history.push” is not so clean. Any other ideas?

0reactions
devmetalcommented, Jan 17, 2018

@SBoudrias Hi, i found a workaround. I don’t know what cause my original problem, but i find a solution that may help us to further investigations. Maybe i was wrong a whole time and this is the actually behavior that we expect.

So, the child component, call now for example <Foo> isn’t a root level component, so the <Foo> not in the pages. It just wrapped a HOC, withRouter. Also in the <Home> component is wrapped the withData HOC from apollo example. The <Home> has a url property by default from the server, and when somewhere in the hierarchy, i call the Router.push(…, …, { shallow: true }), actually nothing else, but the Home component updating. This led me to workaround, i have to propagate the query parameter from <Home> to <Foo> and now the thing is working as i expect, but the solution is not 100% for me.

So, this is the expected behavior or its some strange issue with next?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Silently update url without triggering route in vue-router
The solution here is to use an alias so Vue router treats multiple urls as the same route. This question is not about...
Read more >
How do I use JavaScript to modify the URL without reloading ...
Learn all of the options JavaScript provides for modifying the URL of the current page in the browser without reloading the page.
Read more >
Silently Update URL in Nuxt 3 | Cody Bontecou
Update your URL using vue-router within Nuxt 3 so that your page does not refresh on variable change.
Read more >
Silent install Azure Active Directory Application Proxy connector
Covers how to perform an unattended installation of Azure Active Directory Application Proxy Connector to provide secure remote access to ...
Read more >
Silent Installation Properties for Horizon Agent - VMware Docs
You can include specific properties when you silently install Horizon ... See "Configuring URL Content Redirection in the Configuring Remote ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found