I stumbled upon a bug after putting in navigation (router) inside a sidebar.
Problem + fix:Uncaught TypeError: Cannot read property 'removeEventListener' of null
at Sidebar.unbindMaskClickListener (Sidebar.js:130)
at Sidebar.componentWillUnmount (Sidebar.js:58)
...
Code: Select all
key: 'componentWillUnmount',
value: function componentWillUnmount() {
this.disableModality();
this.unbindMaskClickListener();
}
Code: Select all
key: 'disableModality',
value: function disableModality() {
if (this.mask) {
document.body.removeChild(this.mask);
if (this.props.blockScroll) {
_DomHandler2.default.removeClass(document.body, 'ui-overflow-hidden');
}
this.mask = null;
}
}
Code: Select all
key: 'unbindMaskClickListener',
value: function unbindMaskClickListener() {
if (this.maskClickListener) {
this.mask.removeEventListener('click', this.maskClickListener);
this.maskClickListener = null;
}
}
Code: Select all
this.mask = null
Code: Select all
this.mask.removeEventListener('click', this.maskClickListener);
fix: switch the function calls around like so:
Code: Select all
key: 'componentWillUnmount',
value: function componentWillUnmount() {
this.unbindMaskClickListener();
this.disableModality();
}