Skip to content

An undefined/null element triggers onEnterViewport #184

@gmp

Description

@gmp

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} />

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions