LazyComponent
БесплатноЗапускает вложенные скриптыНе проверен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.
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>.
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.
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
estimatedStyleprop 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
sceneandpidprops are required. They are used to identify the item. Their combination must be unique. - NOTICE: The rule of
bottom,top,left, andrightprops is that to expand the exposure margin of the item. The default value is0px. - NOTICE: Use
unmountOnExitto specify whether the content of the item should be unmounted when it is out of the viewport. - NOTICE:
unloadableis deprecated and kept only for backward compatibility. PreferunmountOnExit.
Установить LazyComponent в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл LazyComponent?
Provide the information about the `<LazyComponent>`. Show the common use cases, basic usage, and critical development Advises.
Как установить скилл LazyComponent?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл LazyComponent запускает скрипты?
Да, скилл несёт исполняемые скрипты. Проверь исходник перед установкой.
Похожие скиллы
frontend-design
Guidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making…
от Anthropicwebapp-testing
Toolkit for interacting with and testing local web applications using Playwright. Supports verifying frontend functionality, debugging UI behavior, capturing…
от Anthropicbrand-guidelines
Applies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand…
от Anthropicweb-artifacts-builder
Suite of tools for creating elaborate, multi-component claude.ai HTML artifacts using modern frontend web technologies (React, Tailwind CSS, shadcn/ui). Use…
от Anthropic