Should I remove event listeners registered like this:
window.addEventListener('resize', callback, { once: true });
During cleanup in React like this:
useEffect(() => {
return () => {
window.removeEventListener('resize', callback, { once: true });
};
}, []);
Or is it completely unnecessary since it will get removed automatically after it has been invoked once? The possibility of the user closing the browser before the event listener gets invoked is small but it's there. So I'm currently thinking that I should remove it during cleanup even though the event listener will get removed automatically after it has been called.