mirror of
https://github.com/Stremio/stremio-web.git
synced 2026-03-11 21:27:05 +00:00
refactor(ContextMenu): simplify useEffect
This commit is contained in:
parent
43a7e8d856
commit
6a2054372f
1 changed files with 2 additions and 6 deletions
|
|
@ -58,12 +58,8 @@ const ContextMenu = ({ children, on, autoClose }: Props) => {
|
|||
};
|
||||
|
||||
useEffect(() => {
|
||||
const containers = on.map((ref) => ref.current).filter((element) => !!element);
|
||||
containers.forEach((container) => container.addEventListener('contextmenu', onContextMenu));
|
||||
|
||||
return () => {
|
||||
containers.forEach((container) => container.removeEventListener('contextmenu', onContextMenu));
|
||||
};
|
||||
on.forEach((ref) => ref.current && ref.current.addEventListener('contextmenu', onContextMenu));
|
||||
return () => on.forEach((ref) => ref.current && ref.current.removeEventListener('contextmenu', onContextMenu));
|
||||
}, [on]);
|
||||
|
||||
return active && createPortal((
|
||||
|
|
|
|||
Loading…
Reference in a new issue