Socket
Socket
Sign inDemoInstall

react-lazily-render

Package Overview
Dependencies
7
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    react-lazily-render

Lazily render react components


Version published
Weekly downloads
8.1K
increased by18.73%
Maintainers
1
Install size
84.1 kB
Created
Weekly downloads
 

Changelog

Source

1.2.0

  • added the ability to specify the scrollContainer (#7)
  • updated devDependencies that had security issues
  • added react as a peerDependency
  • added the module field in package.json

Readme

Source

react-lazily-render

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)

import React from 'react';
import LazilyRender from 'react-lazily-render';

<div>
  ...lots of content...
  <LazilyRender
    placeholder={<PlaceholderComponent/>}
    content={<ExpensiveComponent/>}
  />
  ...lots of content...
  <LazilyRender>
    {render => render
      ? <ExpensiveComponent/>
      : <PlaceholderComponent/>
    }
  </LazilyRender>
  ...lots of content...
</div>

API

Properties

className

string

The className applied to the wrapping element.

component

string | React.ComponentClass

The wrapping component.

e.g.

<LazilyRender component="span"/>
<LazilyRender component={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 which react-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.

Keywords

FAQs

Last updated on 11 Jun 2019

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc