Answer the question
In order to leave comments, you need to log in
RemoveEventListener in React and IE. How does it work?
Hello! I have this situation: there is a component that hangs an eventListener on the document in componentDidMount . In componentWillUnmount I remove it. It all works well in browsers, except for IE. Ie first performs the function that I passed when creating the listener, and only then removes it (or does not remove it at all, I did not understand). How to be in that case? What's happening?
componentDidMount() {
if (this.props.controls) {
document.addEventListener('click', this.componentSearchListener, false);
document.addEventListener('touchstart', this.componentSearchListener, false);
}
}
componentWillUnmount() {
document.removeEventListener('click', this.componentSearchListener, false);
document.removeEventListener('touchstart', this.componentSearchListener, false);
}
Answer the question
In order to leave comments, you need to log in
Igor Shumilovsky : what if we hang window.removeEventListener and window.addEventListener?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question