Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Delay mounting expensive components until a placeholder component has been scrolled into view.

NotificationsYou must be signed in to change notification settings

jameslnewell/react-lazily-render

Repository files navigation

Build Status

Lazily render react components.

Delay mounting expensive components until a placeholder component has been scrolled into view.

Installation

npm install --save react-lazily-render

Usage

Example (source)

importReactfrom'react';importLazilyRenderfrom'react-lazily-render';<div>  ...lots of content...<LazilyRenderplaceholder={<PlaceholderComponent/>}content={<ExpensiveComponent/>}/>  ...lots of content...<LazilyRender>{render=>render      ?<ExpensiveComponent/>      :<PlaceholderComponent/>}</LazilyRender>  ...lots of content...</div>

API

Properties

className

string

TheclassName applied to the wrapping element.

component

string | React.ComponentClass

The wrapping component.

e.g.

<LazilyRendercomponent="span"/><LazilyRendercomponent={MyComponent}/>

offset

number | {top?: number, right?: number, bottom?: number, left?: number}

An offset applied to the element for calculating whether the component has been scrolled into view.

You can specify individual values for each side, or a single value used for all sides.

placeholder

React.Node

Rendered when the component hasn't been scrolled into view.

content

React.Node

Rendered when the component has been scrolled into view.

children

(render: boolean) => React.Node

Called to render something depending on whether the component has been scrolled into view.

onRender

() => void

Called when the component becomes visible for the first time.

scrollContainer

HTMLElement | undefined

The container whichreact-lazily-render listens to for scroll events.

This property can be used in a scenario where you want to specify your own scroll container - e.g. if the component you are rendering is asynchronously added to the DOM.

About

Delay mounting expensive components until a placeholder component has been scrolled into view.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors6


[8]ページ先頭

©2009-2025 Movatter.jp