Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix based on #4 #7

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

fix based on #4 #7

wants to merge 2 commits into from

Conversation

ddikodroid
Copy link

No description provided.

src/index.tsx Outdated
@@ -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);
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)

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