How to avoid remo for each handler and do it for everyone at once?

componentWillUnmount() { renderer.domElement.removeEventListener('mousemove', this.onMouseMoveObj, false); renderer.domElement.removeEventListener('mousedown', this.onMouseDownObj, false); renderer.domElement.removeEventListener('mouseup', this.onMouseUpObj, false); 

}

    2 answers 2

    Try this method:

     componentWillUnmount() { var oldElem = renderer.domElement; var newElem = oldElem.cloneNode(true); oldElem.parentNode.replaceChild(newElem, oldElem); } 

    The only thing is that this method will also clear all listeners in the children for renderer.domElement

      The first thing that catches your eye is why do you need event listeners?

      What standard synthetic events do not suit?

      They themselves will be added when the component is mounted and will be deleted themselves when unmounted.

      • But how can I use them in this case? - werty