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

feat: add support for fallbackInView #521

Merged
merged 3 commits into from
Dec 9, 2021
Merged

Conversation

thebuilder
Copy link
Owner

This is solution for #495 that adds support for a fallbackInView value.

You can set the fallback globally:

import { defaultFallbackInView } from 'react-intersection-observer';
defaultFallbackInView(true); // or 'false'

You can also define the fallback locally on useInView or <InView> as an
option. This will override the global fallback value.

import React from 'react';
import { useInView } from 'react-intersection-observer';

const Component = () => {
  const { ref, inView, entry } = useInView({
    fallbackInView: true,
  });

  return (
    <div ref={ref}>
      <h2>{`Header inside viewport ${inView}.`}</h2>
    </div>
  );
};

@codesandbox-ci
Copy link

codesandbox-ci bot commented Nov 22, 2021

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit d30d0e9:

Sandbox Source
useInView Configuration
InView render props Configuration
InView plain children Configuration

@vercel
Copy link

vercel bot commented Nov 23, 2021

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/the-builder/react-intersection-observer/HZi7fsP5Jj4WmiimDeKrKUcst44v
✅ Preview: https://react-intersection-observer-git-feature-fall-f87a33-the-builder.vercel.app

@dale-french
Copy link

dale-french commented Dec 9, 2021

Thanks for this 🙌

Any idea when this will get released?

@thebuilder
Copy link
Owner Author

Just want to make sure it's the right approach. :)

@thebuilder thebuilder merged commit aa50422 into master Dec 9, 2021
@thebuilder thebuilder deleted the feature/fallback-inview branch December 9, 2021 22:53
@thebuilder
Copy link
Owner Author

🎉 This PR is included in version 8.33.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@thebuilder thebuilder linked an issue Dec 9, 2021 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Can't find variable: IntersectionObserver
3 participants