Skip to content
Back to skills

Lynx Ui Deferred Component

ASecurity

Use DeferredComponent to delay mounting ReactLynx content by frames, reserve layout space, show a placeholder, and observe layout after the content appears.

  • 119 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added September 21, 2026
designreactgit

Security analysis

A100/100

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

Scanned September 21, 2026

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

Installs into .claude/skills of the current project.

Are you the author of Lynx Ui Deferred Component?

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

Security grade badge for Lynx Ui Deferred Component
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/lynx-family-lynx-ui-deferred-component/badge)](https://www.skillsdirectory.com/skills/lynx-family-lynx-ui-deferred-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: DeferredComponent
description: Use DeferredComponent to delay mounting ReactLynx content by frames, reserve layout space, show a placeholder, and observe layout after the content appears.
---

# lynx-ui-deferred-component SKILL

## Core Capabilities

`DeferredComponent` postpones mounting a child until its wrapper has completed its first layout. It supports additional frame delays and an optional placeholder. Use it when non-critical content should mount after the surrounding page starts laying out.

`LazyComponent` is the component for mounting based on viewport visibility. `DeferredComponent` does not observe visibility or virtualize a collection.

## AI Coding Guide

### Minimal Usable Example

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

function DeferredPanel() {
  return (
    <DeferredComponent
      estimatedStyle={{ width: '100%', minHeight: '120px' }}
      placeholder={<text>Preparing content…</text>}
    >
      <view>
        <text>Content mounted after the first layout.</text>
      </view>
    </DeferredComponent>
  )
}
```

### Recommended Prompt Formula

> **Scenario**: Defer the non-critical `[content]` on a ReactLynx screen.
> **Requirements**: Mount it after `[frame count]` frames and reserve `[estimated dimensions]`.
> **Appearance**: Use `[placeholder content]` during the delay and style the child with `[theme and classes]`.
> **Behavior**: Report `[layout handling]` after the content appears and replay the delay when `[remount condition]` occurs.

## Use Cases and Best Practices

### Choose the delay

- The default `delayFrames={1}` shows children after the first wrapper layout.
- A finite value greater than `1` waits for `delayFrames - 1` animation frames after that initial layout.
- A value below `1` or a non-finite value (`NaN`, `Infinity`, or `-Infinity`) renders children directly. In this mode, there is no wrapper, placeholder, estimated style, or wrapper layout callback.
- Use whole frame counts. The delay follows frame scheduling and is not a fixed duration in milliseconds.

```tsx
<DeferredComponent
  delayFrames={3}
  estimatedStyle={{ width: '100%', minHeight: '160px' }}
  placeholder={<text>Preparing details…</text>}
>
  <Details />
</DeferredComponent>
```

Keep expensive rendering inside the child component. Calculations performed in the parent before creating the child still run immediately.

### Reserve space and observe layout

`estimatedStyle` remains on the wrapper after the child appears. Use a fixed `height` for content with a known final size, or `minHeight` when the content should grow. Apply visual styles to the child and placeholder with their own CSS classes.

```tsx
<DeferredComponent
  estimatedStyle={{ width: '100%', minHeight: '120px' }}
  onLayoutChange={({ width, height }) => {
    console.log(
      `[deferred-panel][onLayoutChange] size, width: ${width}, height: ${height}`,
    )
  }}
>
  <ResizableContent />
</DeferredComponent>
```

`onLayoutChange` receives `{ width, height }` from wrapper layout events after the child appears. The initial event that starts the delay is not forwarded. This callback is not a loading-complete notification; an event depends on layout changing.

### Replay the delay

The child stays mounted after it appears. Unmount and mount `DeferredComponent`, or give it a new React `key`, to restart the placeholder and delay. The [examples](https://github.com/lynx-family/lynx-ui/tree/main/apps/examples/DeferredComponent) use `Button` to demonstrate both patterns.

## FAQ

### Why is my placeholder barely visible?

The default delay is only the initial layout. Use a larger frame count when demonstrating the placeholder; choose production delays based on the screen's needs.

### Why does changing delayFrames not replay an already visible child?

The component preserves its visible state until it is remounted. Change its `key` or unmount it when a new delay is needed.

### Can I call a method through DeferredComponentRef?

`DeferredComponentRef` is an empty reserved interface. It exposes no imperative methods. Use mounting and props to control the component.

## Sub-components and Public Types

`DeferredComponent` has no sub-components. Its public types are `DeferredComponentProps` and `DeferredComponentRef`.

Files in this skill

  • LICENSE11.1 KB
  • README.md1 KB
  • README_zh.md1019 B
  • SKILL.md4.2 KB
  • __tests__/DeferredComponent.test.tsx4.9 KB
  • __tests__/tsconfig.json479 B
  • docs/APIReference.mdx3.3 KB
  • docs/README.mdx314 B
  • docs/README.zh.mdx293 B
  • package.json1.3 KB
  • rslib.config.ts338 B
  • src/index.tsx1.8 KB
  • src/styles.css84 B
  • src/types/index.docs.ts2.2 KB
  • src/types/index.ts301 B
  • tsconfig.docs.json122 B
  • tsconfig.json225 B
  • vitest.config.ts537 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.