react-intersection-loader
TypeScript icon, indicating that this package has built-in type declarations

0.1.0 • Public • Published

React Intersection Loader

Lazy load your components only when they're visible.

release checks version

react-intersection-loader-demo

import { intersectionLoader } from 'react-intersection-loader';

// This is will be imported (lazy loaded) only when the user is about to see it.
const MyComponent = intersectionLoader(() => import('./MyComponent'));

export default function App() {
  return (
    <div>
      <div
        style={{
          width: '100vw',
          height: '100vh',
        }}
      >
        <h1>I am a viewport size</h1>
      </div>
      <MyComponent />
    </div>
  );
}

Currently only supported with hooks

Examples

Testing is a top priority. Therefore I created fixtures with various use-cases of projects that use this library. You can check it out here.

I build the fixtures using webpack, serve them and test them with playwright.

Installation

npm i react-intersection-loader

or

yarn add react-intersection-loader

Package Sidebar

Install

npm i react-intersection-loader@0.1.0

Version

0.1.0

License

MIT

Unpacked Size

43.7 kB

Total Files

27

Last publish

Collaborators

  • tzachb