From 9db6333044aba68016fcc62235b7f1328afdd1ad Mon Sep 17 00:00:00 2001 From: Andriy Malivanchuk Date: Tue, 8 Jun 2021 21:10:39 +0300 Subject: [PATCH] PR from https://github.com/alexkatz/react-tiny-popover/pull/112 --- src/Popover.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Popover.tsx b/src/Popover.tsx index 4b49adf..0416250 100644 --- a/src/Popover.tsx +++ b/src/Popover.tsx @@ -179,7 +179,9 @@ export const Popover = forwardRef( ); const handleWindowResize = useCallback(() => { - window.requestAnimationFrame(() => positionPopover()); + if(childRef?.current){ + window.requestAnimationFrame(() => positionPopover()); + } }, [positionPopover]); useEffect(() => {