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

An undefined/null element triggers onEnterViewport #184

Open
gmp opened this issue Nov 23, 2017 · 0 comments
Open

An undefined/null element triggers onEnterViewport #184

gmp opened this issue Nov 23, 2017 · 0 comments

Comments

@gmp
Copy link

gmp commented Nov 23, 2017

Certainly possible I'm misinterpreting the code, but it appears as if _onEnterViewport is purposefully triggered if/when the tracked element does not exist. See https://github.com/yahoo/react-i13n/blob/master/src/libs/ViewportDetector.js#L56

In practice, I'm also noticing that components who's render return value ends up as null are being tracked as entering the viewport, but this seems counterintuitive.

contrived example:

const ConditionalComponent = (props) => {
    return props.shouldRender ? <div>Yay!</div> : null;
};

const i13nConditionalComponent = createI13nNode(ConditionalComponent);

// triggers viewport as intended when in view
<ConditionalComponent shouldRender />

// still triggers viewport as maybe(?) unintended on init
<ConditionalComponent shouldRender={false} />
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

No branches or pull requests

1 participant