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.

Guard against SSR leaks in <Router> constructor

See original GitHub issue

We should have a guard around the history.listen call in the <Router> constructor to be sure we are in a persistent environment first (see https://github.com/ReactTraining/react-router/issues/6060#issuecomment-424575126).

The ideal place for this listener would be componentDidMount, but we can’t move it there and preserve backwards compatibility with existing code. It would be a breaking change, so we can talk about doing that in v5.

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
timdorrcommented, Oct 1, 2018

Prior to the 4.4 changes, we did some wacky stuff with checking if we were in a staticContext or not. We could do the same thing to maintain the same behavior. 🤷‍♂️

0reactions
mjacksoncommented, Oct 1, 2018

Completely agree, @timdorr. I’m just concerned that someone might be relying on this behavior in a SSR scenario and we will break their app with 4.4 if we change it. Again, I’m totally down with changing this in v5.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Guard against SSR leaks in <Router> constructor · Issue #6363 ...
We should have a guard around the history.listen call in the constructor to be sure we are in a persistent environment first (see...
Read more >
react-router-ssr - npm
react-router-ssr ... It has a protection against leaking your data. Only subscribed data will be available just the way it would be on...
Read more >
Preventing Memory Leaks in Angular Observables with ...
Learn how to use ngOnDestroy to prevent memory leaks in your Angular JavaScript web applications.
Read more >
SSR 5.5 Release Notes | SSN Docs
I95-48685 GUI and/or PCLI unresponsive: Resolved an issue where on an HA conductor the user interface would become unresponsive if a managed router...
Read more >
Angular SSR - Cannot read properties of undefined (reading ...
Unsubscribe observables and detach event handlers to avoid memory leaks. Called just before Angular destroys the directive/component.
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