mirror of
https://github.com/facebook/docusaurus.git
synced 2025-06-01 10:22:30 +02:00
fix(v2): remove event listeners on Tabs component unmount (#3599)
This commit is contained in:
parent
8f5c632cdf
commit
da6268911c
2 changed files with 10 additions and 0 deletions
|
@ -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 (
|
||||
|
|
|
@ -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 (
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue