New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

react-infinite-virtual-scroll

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-infinite-virtual-scroll

infinite virtual scroll with react and async iterator

  • 0.0.6
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
decreased by-66.67%
Maintainers
1
Weekly downloads
 
Created
Source

React Infinite Virtual Scroll

demo: github page

Why

There are already many virtualize list libraries out there, but I can't find one that satisfies all these, so I decided to create one myself.

  • Simple: no dependencies other than react
  • Allow dynamic row height
    • But the viewport height must be fixed.
    • Set the viewport height by passing style prop.
  • Utilizing async iterable feature which is awesome.
  • High Performance

How

Important: You Must set a fixed height via style prop for it to work!

import InfiniteVirtualScroll from "react-infinite-virtual-scroll"

function Foo(){
    const [searchText,setSearchText] = useState("")
    const dataSource = useMemo(()=>async function *GetData(){
        let total = Infinity
        let page = 0
        let pageSize = 20
        while(page * pageSize < total){
            const {data,total:remoteTotal} = await fetch("/data",{
                method:"post",
                body:JSON.stringify({
                    page,
                    pageSize:pageSize
                })
            })
            page = page + 1
            total = remoteTotal
            yield data
        }
    },[searchText])

    return <div>
        <InfiniteVirtualScroll dataSource={dataSource} style={{height:"200vh" /** Height Must Not Be "auto" For It To Work */  }}>  
            {(rows)=>{
                return rows.map(row=><div key={row.id}>
                    <ItemDisplayComponent item={item} />
                </div>)
            }}
        </InfiniteVirtualScroll>
    </div>
}

License

Anti996

FAQs

Package last updated on 23 Mar 2021

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc