fix(v2): remove event listeners on Tabs component unmount (#3599)

This commit is contained in:
Alexey Pyltsyn 2020-10-16 19:15:48 +03:00 committed by GitHub
parent 8f5c632cdf
commit da6268911c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 0 deletions

View file

@ -106,6 +106,11 @@ function Tabs(props: Props): JSX.Element {
useEffect(() => {
window.addEventListener('keydown', handleKeyboardEvent);
window.addEventListener('mousedown', handleMouseEvent);
return () => {
window.removeEventListener('keydown', handleKeyboardEvent);
window.removeEventListener('mousedown', handleMouseEvent);
};
}, []);
return (

View file

@ -93,6 +93,11 @@ function Tabs(props: Props): JSX.Element {
useEffect(() => {
window.addEventListener('keydown', handleKeyboardEvent);
window.addEventListener('mousedown', handleMouseEvent);
return () => {
window.removeEventListener('keydown', handleKeyboardEvent);
window.removeEventListener('mousedown', handleMouseEvent);
};
}, []);
return (