Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export interface Props {

const VisibilitySensor: React.FC<Props> = (props) => {
const myView: any = useRef(null);
const [lastValue, setLastValue] = useState<boolean>(false);
const [lastValue, setLastValue] = useState<boolean | null>(null);
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, me again with some feedback. I'm trying to understand why we go for a double type declaration here. What's the scenario where setting this to false (instead of null), and removing line 29, that it would still show undesired behavior?

Happy to merge this PR, just trying to wrap my head around why this would work.

const [dimensions, setDimensions] = useState<IDimensionData>({
rectTop: 0,
rectBottom: 0,
Expand All @@ -26,7 +26,6 @@ const VisibilitySensor: React.FC<Props> = (props) => {
let interval: any = null;

useEffect(() => {
setLastValue(false);
startWatching();
isInViewPort();
return stopWatching;
Expand Down