From 9a03cc561d6a5b5030bc9c203e4a48deda1da954 Mon Sep 17 00:00:00 2001 From: Ahmad Syarifuddin Randiko Date: Thu, 31 Mar 2022 00:32:28 +0700 Subject: [PATCH 1/2] fix based on #4 --- src/index.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/index.tsx b/src/index.tsx index 607396d..2c50bd1 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -16,7 +16,7 @@ export interface Props { const VisibilitySensor: React.FC = (props) => { const myView: any = useRef(null); - const [lastValue, setLastValue] = useState(false); + const [lastValue, setLastValue] = useState(null); const [dimensions, setDimensions] = useState({ rectTop: 0, rectBottom: 0, @@ -26,7 +26,6 @@ const VisibilitySensor: React.FC = (props) => { let interval: any = null; useEffect(() => { - setLastValue(false); startWatching(); isInViewPort(); return stopWatching; From 0cbe8ec59ac2400f2eabce78b010ad2ded782837 Mon Sep 17 00:00:00 2001 From: Ahmad Syarifuddin Randiko Date: Sat, 9 Apr 2022 14:56:07 +0700 Subject: [PATCH 2/2] Update index.tsx --- src/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.tsx b/src/index.tsx index 2c50bd1..7f7d1c0 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -16,7 +16,7 @@ export interface Props { const VisibilitySensor: React.FC = (props) => { const myView: any = useRef(null); - const [lastValue, setLastValue] = useState(null); + const [lastValue, setLastValue] = useState(null); const [dimensions, setDimensions] = useState({ rectTop: 0, rectBottom: 0,