Skip to content

Conversation

@ddikodroid
Copy link

No description provided.

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

Choose a reason for hiding this comment

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

👋🏽 Argument of type 'null' is not assignable to parameter of type 'boolean'. Why can't we stick with false?

Copy link
Author

Choose a reason for hiding this comment

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

just following from this #4 (comment)

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
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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants