# react-intersection-loader

> Load react component lazily when the component is visible

Latest version **0.2.2** (published 2024-04-27) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-intersection-loader
pnpm add react-intersection-loader
yarn add react-intersection-loader
bun add react-intersection-loader
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.2 |
| Published | 2024-04-27 |
| First published | 2022-04-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 28.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | tzachbon |
| Maintainers | tzachb |
| Keywords | react, react-intersection-loader, instersection-observer, lazy-load, typescript, javascript |

## Links

- npm: https://www.npmjs.com/package/react-intersection-loader
- Homepage: https://github.com/tzachbon/react-intersection-loader#readme
- Issues: https://github.com/tzachbon/react-intersection-loader/issues
- npm.io page: https://npm.io/package/react-intersection-loader

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 0.2.2 (latest) — 2024-04-27
- 0.2.1 — 2022-05-13
- 0.2.0 — 2022-05-06
- 0.1.2 — 2022-05-05
- 0.1.1 — 2022-05-05
- 0.1.0 — 2022-05-01
- 0.0.4 — 2022-04-30
- 0.0.3 — 2022-04-29
- 0.0.2 — 2022-04-29
- 0.0.1 — 2022-04-29
- 0.0.0 — 2022-04-29

## README

# React Intersection Loader

Lazy load your components only when they're visible.

[![release](https://badgen.net/github/release/tzachbon/react-intersection-loader)](https://github.com/tzachbon/react-intersection-loader/releases)
[![checks](https://badgen.net/github/checks/tzachbon/react-intersection-loader)](https://github.com/tzachbon/react-intersection-loader/actions)
[![version](https://badgen.net/npm/v/react-intersection-loader)](https://www.npmjs.com/package/react-intersection-loader)

![react-intersection-loader-demo](https://github.com/tzachbon/react-intersection-loader/blob/master/react-intersection-loader.gif?raw=true)

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

// This 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>
  );
}

```

### Support

Since this uses react, support verity of use cases is a most.
#### React

Currently only supported with hooks, react `>=16.8.0`

#### SSR (Server-side rendering)

Full support of SSR and hydration!

## 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](./packages/react-intersection-loader/test/fixtures/).\
\
I build the fixtures using [webpack](https://webpack.js.org/), serve them and test them with [playwright](https://playwright.dev/).



## Installation

```sh
npm i react-intersection-loader
```
or

```sh
yarn add react-intersection-loader
```

---
_Source: https://npm.io/package/react-intersection-loader · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
