sekoyo/react-image-crop

Memory leak risk due to event listeners not removed on componentWillUnmount

rockinghelvetica opened this issue · 1 comments

componentWillUnmount() {
if (this.resizeObserver) {
this.resizeObserver.disconnect()
}
}

I'm investigating an interaction glitch with the crop tool, and tangentially noticed that componentWillUnmount assumes it won't occur in the middle of the crop interaction. I imagine this is true in most applications, but it feels safer to ensure the events get torn down. Thoughts?

componentWillUnmount() {
    if (this.resizeObserver) {
        this.resizeObserver.disconnect()
    }
    // Ensure all event listeners are removed
    this.unbindDocMove()
}
sekoyo commented

Yep makes sense thanks, pushed to master so will go up in next release