In our situation, the burger menu component only exists after the user has logged into the site. One of the options in the menu is the Logout option.
When the user selects Logout, the timer gets created (because the menu is changing from visible to invisible again) and then the component gets unmounted entirely. When the timeout function then fires it tries to invoke code on a component that no longer exists to modify settings on the pageWrapId and outerWrapId divs that also no longer exist.
The menuFactory sets up a timer function to be run when the menu visibility is toggled here: https://github.com/negomi/react-burger-menu/blob/3487781faf0b9bf7b8664e2e5fe59b3a341c9380/src/menuFactory.js#L52-L58
In our situation, the burger menu component only exists after the user has logged into the site. One of the options in the menu is the Logout option.
When the user selects Logout, the timer gets created (because the menu is changing from visible to invisible again) and then the component gets unmounted entirely. When the timeout function then fires it tries to invoke code on a component that no longer exists to modify settings on the pageWrapId and outerWrapId divs that also no longer exist.
The
componentWillUnmount
function needs to have the same code in https://github.com/negomi/react-burger-menu/blob/3487781faf0b9bf7b8664e2e5fe59b3a341c9380/src/menuFactory.js#L52 added to this function, so that if the menu component is unmounted as a result of activating an item in the menu it cancels the timer function properly.