Skip to content
Back to skills

Lynx Ui Lazy Component

ASecurity

Provide the information about the `<LazyComponent>`. Show the common use cases, basic usage, and critical development Advises.

  • 119 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added June 5, 2026
developmenttypescript

Security analysis

A100/100

Pro scans all 16 files and shows the line behind each finding

Scanned June 5, 2026

npx -y skills add lynx-family/lynx-ui --skill lynx-ui-lazy-component --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Lynx Ui Lazy Component?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Lynx Ui Lazy Component
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/lynx-family-lynx-ui-lazy-component/badge)](https://www.skillsdirectory.com/skills/lynx-family-lynx-ui-lazy-component)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: LazyComponent
description: Provide the information about the `<LazyComponent>`. Show the common use cases, basic usage, and critical development Advises.
---

# lynx-ui-lazy-component SKILL

`<LazyComponent>` is a component that lazy loads the content when it is visible in the viewport.

## 1. Common Use Cases

- **Offscreen rendering in scrollable containers**: Display the content of the page only when it is visible in the viewport of scrollable containers such as `<ScrollView>`, `<List>`, `<FeedList>`, etc. Usually used for speed up the initial loading time.
- **Virtualized List**: Embed `<LazyComponent>` in the slot of `<ScrollView>` so that the content of the items are only loaded when they are visible in the viewport.

## 2. Basic Usage

`<LazyComponent>` is used to display the content of the page only when it is visible in the viewport.

```tsx
import { LazyComponent } from '@lynx-js/lynx-ui'

function App() {
  return (
    <view>
      <LazyComponent
        scene={'scene'}
        pid={'pid'}
        estimatedStyle={{ width: '1px', height: '1px' }}
      >
        <RealItem />
      </LazyComponent>
    </view>
  )
}
```

## 3. Example for build Virtualized-List

You can build a virtualized list by embedding `<LazyComponent>` in the slot of `<ScrollView>`.

```tsx
import { LazyComponent } from '@lynx-js/lynx-ui'
import { ScrollView } from '@lynx-js/lynx-ui'

function App() {
  return (
    <ScrollView
      scrollOrientation='vertical'
      lazyOptions={{ enableLazy: false }}
      style={{ width: '100%', height: '400px' }}
    >
      {
        // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
        [...Array(20)]
          .map((_, index) => index)
          .map((_item, index) => (
            <LazyComponent
              key={index}
              scene={'scene'}
              pid={`pid_${index}`}
              estimatedStyle={{ width: '100%', height: '100px' }} // make sure the estimated size is equal to the real size
              unmountOnExit
            >
              <view
                style={{
                  width: '100%',
                  height: `${300 + index * 10}px`,
                  padding: '5px',
                  border: '50px red',
                }}
              >
                <text>item</text>;
              </view>
            </LazyComponent>
          ))
      }
    </ScrollView>
  )
}
```

## 4. Example for adjust exposure-margin

You can adjust the exposure margin of `<LazyComponent>` by setting the `bottom`, `top`, `left`, and `right` props. So that the content of the item is loaded earlier than it is visible in the viewport.

```tsx
import { LazyComponent } from '@lynx-js/lynx-ui'

function App() {
  return (
    <view>
      <LazyComponent
        scene={'scene'}
        pid={'pid'}
        bottom='200px'
        top='200px'
        left='200px'
        right='200px'
        estimatedStyle={{ width: '1px', height: '1px' }}
      >
        <RealItem />
      </LazyComponent>
    </view>
  )
}
```

## 5. Critical Development Advises

- **MUST**: The `estimatedStyle` prop is required. It is an object that specifies the estimated size of the content of the item. The estimated size could be equal to or smaller than the real size of the content.
- **MUST**: The `scene` and `pid` props are required. They are used to identify the item. Their combination must be unique.
- **NOTICE**: The rule of `bottom`, `top`, `left`, and `right` props is that to expand the exposure margin of the item. The default value is `0px`.
- **NOTICE**: Use `unmountOnExit` to specify whether the content of the item should be unmounted when it is out of the viewport.
- **NOTICE**: `unloadable` is deprecated and kept only for backward compatibility. Prefer `unmountOnExit`.

Files in this skill

  • CHANGELOG.md1.6 KB
  • LICENSE11.1 KB
  • README.md1.2 KB
  • README_zh.md971 B
  • SKILL.md3.7 KB
  • docs/APIReference.mdx5.7 KB
  • docs/README.mdx607 B
  • docs/README.zh.mdx589 B
  • package.json1.1 KB
  • rslib.config.ts338 B
  • src/index.tsx3.8 KB
  • src/styles.css46 B
  • src/types/index.docs.ts3.3 KB
  • src/types/index.ts225 B
  • tsconfig.docs.json122 B
  • tsconfig.json141 B

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.