diff --git a/CHANGELOG.md b/CHANGELOG.md index d2bb13bf36..4efc4e4163 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ This project adheres to [Semantic Versioning](https://semver.org/). ## Fixed +- [#2489](https://github.com/plotly/dash/pull/2489) Fix location change event handling when `Location` objects are removed from the layout. Event handlers would not be removed and eventually change props of a random DOM element, fix [#1346](https://github.com/plotly/dash/issues/1346) - [#2498](https://github.com/plotly/dash/pull/2498) Fix error when caching callbacks which return `Patch` objects by making `Patch` objects picklable - [#2491](https://github.com/plotly/dash/pull/2491) Fix clientside inline function name not found, fix [#2488](https://github.com/plotly/dash/issues/2488) diff --git a/components/dash-core-components/src/components/Location.react.js b/components/dash-core-components/src/components/Location.react.js index a9aa6916ad..bf534e486b 100644 --- a/components/dash-core-components/src/components/Location.react.js +++ b/components/dash-core-components/src/components/Location.react.js @@ -121,6 +121,14 @@ export default class Location extends Component { this.updateLocation(this.props); } + componentWillUnmount() { + window.onpopstate = () => {}; + window.removeEventListener( + '_dashprivate_pushstate', + this.onLocationChange + ); + } + UNSAFE_componentWillReceiveProps(nextProps) { this.updateLocation(nextProps); }