Socket
Socket
Sign inDemoInstall

lazylist-react

Package Overview
Dependencies
6
Maintainers
1
Versions
44
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    lazylist-react

list lazy loading of react


Version published
Weekly downloads
73
increased by32.73%
Maintainers
1
Install size
296 kB
Created
Weekly downloads
 

Readme

Source

lazylist-react

NPM JavaScript Style Guide

Please understand before using

This is a lazy loading component based on intersectionObserver.The child elements under this component render one by default, and When the rendered subcomponent appears in the view, it continues to render the next one, and so on. Each child element is wrapped in a layer of warpTag, You can define its type. The version of react must be greater than or equal to 16.8. Because the component form is hooks.

Install

npm install --save lazylist-react
// or
yarn add lazylist-react

Props

attributevaluetypedescribe
classNamestringthe classname of container
tagdefault: divstringthe nodetype of container
renderCountdefault: 1numberNumber of DOMS per rendering
thresholddefault:0numberRendered elements will continue to render at this scale in the viewport
rootdefault:windowHTMLElementView
warpTagdefault:divHTMLElementA label that wraps each child element
renderCallback(containerInfo,containerVdom,index) => voidCallback function with standard rendering quantity
equalityCheckLimitdefault:100numberLimit for equality check of children keys

Usage

import React from 'react'
import LazyList from 'lazylist-react'

const Example = () => {
  const data = [
  {
    title:'列表1',
    img:'http://xxxx',
    component:<Item title='列表1'/>
  },
  {
    title:'列表2',
    img:'http://xxxx',
    component:<Item title='列表2'/>
  },
  {
    title:'列表3',
    img:'http://xxxx',
    component:<Item title='列表3'/>
  },
]
  return(
    <LazyList>
      {
        data.map(info => {
          return(
            <div>
              <h3>{info.title}</h3>
              <img src={info.img}/>
              {info.component}
            </div>
          )
        })
      }
    </LazyList>
  )
}

License

MIT © mayu888

Keywords

FAQs

Last updated on 11 Mar 2022

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