# component-lazy-loader

> Component Lazy Loader

Latest version **1.0.5** (published 2021-02-17) · ISC license · 0 weekly downloads

## Install

```sh
npm install component-lazy-loader
pnpm add component-lazy-loader
yarn add component-lazy-loader
bun add component-lazy-loader
```

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.5 |
| Published | 2021-02-17 |
| First published | 2021-02-15 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 6.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | bekirburak.aslan@trendyol.com |
| Maintainers | trendyol-js |

## Links

- npm: https://www.npmjs.com/package/component-lazy-loader
- Repository: https://github.com/Trendyol/component-lazy-loader
- Homepage: https://github.com/Trendyol/component-lazy-loader#readme
- Issues: https://github.com/Trendyol/component-lazy-loader/issues
- npm.io page: https://npm.io/package/component-lazy-loader

## Recent versions

- 1.0.5 (latest) — 2021-02-17
- 1.0.3 (beta) — 2021-02-17
- 1.0.4 — 2021-02-17
- 1.0.2 — 2021-02-15
- 1.0.1 — 2021-02-15
- 1.0.0 — 2021-02-15

## README

# Lazy Load Components Package

This package helps you load components with IntersectionObserver.

| Statements                                                                  | Branches                                                                  | Functions                                                                  | Lines                                                                  |
| --------------------------------------------------------------------------- | ------------------------------------------------------------------------- | -------------------------------------------------------------------------- | ---------------------------------------------------------------------- |
| ![Statements](https://img.shields.io/badge/Coverage-100%25-brightgreen.svg) | ![Branches](https://img.shields.io/badge/Coverage-100%25-brightgreen.svg) | ![Functions](https://img.shields.io/badge/Coverage-100%25-brightgreen.svg) | ![Lines](https://img.shields.io/badge/Coverage-100%25-brightgreen.svg) |

## Installation

```
yarn install @trendyol/component-lazy-loader
```

## Usage

Example:

```js
import React from "react";
import LazyComponent from "@trendyol/component-lazy-loader";

function App() {
  let length = 100,
    i = 0,
    arr = Array(length);

  while (i < length) arr[i++] = i;
  return (
    <div>
      {arr.map((element, index) => {
        return (
          <LazyComponent
            placeholder={
              <div
                key={index}
                style={{
                  height: 100,
                  backgroundColor: "red",
                  marginBottom: 10,
                }}
              >
                Placeholder
              </div>
            }
            ratio={0.1}
          >
            <div
              key={index}
              style={{
                height: 100,
                backgroundColor: "lightblue",
                marginBottom: 10,
              }}
            >
              Test Component
            </div>
          </LazyComponent>
        );
      })}
    </div>
  );
}
```

## Options

```ts
export interface LazyLoadComponentsProps {
  placeholder: React.Component;
  children: React.Component;
  force?: boolean; // default false
  ratio?: number; // default 0.1
  onVisible?: Function;
}
```

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