Skip to content

Commit 570a1bc

Browse files
committed
Fix browser back button with multiple dcc.Location
Multiple dcc.Location were replacing the others event handlers for 'popstate'. If any dcc.Location was unmounted, there was no event handler left fix #1312
1 parent db23cdc commit 570a1bc

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Diff for: components/dash-core-components/src/components/Location.react.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ export default class Location extends Component {
112112
}
113113

114114
componentDidMount() {
115-
window.onpopstate = this.onLocationChange;
115+
window.addEventListener('popstate', this.onLocationChange);
116116

117117
window.addEventListener(
118118
'_dashprivate_pushstate',
@@ -122,7 +122,7 @@ export default class Location extends Component {
122122
}
123123

124124
componentWillUnmount() {
125-
window.onpopstate = () => {};
125+
window.removeEventListener('popstate', this.onLocationChange);
126126
window.removeEventListener(
127127
'_dashprivate_pushstate',
128128
this.onLocationChange

0 commit comments

Comments
 (0)