From 6d0433d3782cafc5bc7aefeb02f87cae0e18ee4d Mon Sep 17 00:00:00 2001 From: Michiel Dral Date: Mon, 26 Jul 2021 00:34:29 +0200 Subject: [PATCH] Fix `this.unmounted` being true when re-mounted by React React 18 can render componentWillUnmount and then componentDidMount the same instance that was just "willUnmount"-ed. This makes sure we reset `this.unmounted = false` when re-didMount-ing. --- src/index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/index.js b/src/index.js index a44bdb48..db12debb 100644 --- a/src/index.js +++ b/src/index.js @@ -93,6 +93,7 @@ class LocationProvider extends React.Component { state: { refs }, props: { history } } = this; + this.unmounted = false; history._onTransitionComplete(); refs.unlisten = history.listen(() => { Promise.resolve().then(() => {