Gathering detailed insights and metrics for react-virtual-dynamics
Gathering detailed insights and metrics for react-virtual-dynamics
npm install react-virtual-dynamics
Typescript
Module System
Node Version
NPM Version
64.3
Supply Chain
91.7
Quality
83.7
Maintenance
100
Vulnerability
88
License
TypeScript (75.64%)
HTML (18.6%)
CSS (5.76%)
Love this project? Help keep it running — sponsor us today! 🚀
Total Downloads
1,218
Last Day
4
Last Week
17
Last Month
55
Last Year
1,218
2 Stars
61 Commits
2 Watching
1 Branches
1 Contributors
Minified
Minified + Gzipped
Latest Version
1.0.16
Package Id
react-virtual-dynamics@1.0.16
Unpacked Size
18.52 kB
Size
6.74 kB
File Count
10
NPM Version
10.8.0
Node Version
20.10.0
Publised On
26 Jun 2024
Cumulative downloads
Total Downloads
Last day
300%
4
Compared to previous day
Last week
-34.6%
17
Compared to previous week
Last month
52.8%
55
Compared to previous month
Last year
0%
1,218
Compared to previous year
A React component for efficiently rendering large lists or grids of items using virtualization. This component improves performance by only rendering items that are currently visible in the viewport. Additionally, it supports infinite scrolling by dynamically loading more data as the user scrolls near the end of the list.
To install the package, run:
1npm install react-virtual-dynamics
Here is a basic example of how to use the VirtualizedList
component:
1import React from 'react'; 2import { VirtualizedList } from 'react-virtual-dynamics'; 3 4const data = Array.from({ length: 1000 }).map((_, i) => i + 1); 5 6const App = () => { 7 return ( 8 <VirtualizedList 9 dataLength={data.length} 10 viewportHeight={500} 11 itemHeight={100} 12 gap={10} 13 renderItem={(index, style) => ( 14 <div key={index} style={style}> 15 {data[index]} 16 </div> 17 )} 18 /> 19 ); 20}; 21 22export default App;
Prop | Type | Default | Description |
---|---|---|---|
dataLength | number | The total number of items in the data set. | |
viewportHeight | number | The height of the viewport for the virtualized list. | |
gridColumns | number | 1 | The number of columns for grid layout. Set to 1 for a single column (list layout). |
loadMore | () => void | null | Optional function to load more items when the user scrolls near the bottom of the list. |
isLoading | boolean | false | Optional boolean to show a loading indicator when more items are being loaded. |
renderItem | (index: number, style: React.CSSProperties) => React.ReactNode | Function to render an item. Receives the index and a style object for positioning. | |
itemHeight | number | The height of a single item. | |
gap | number | The gap between items in the grid. |
This example demonstrates how to use the VirtualizedList
component with infinite scrolling. The loadMore
function is triggered to load additional items as the user scrolls near the bottom of the list.
1import React, { useState } from 'react'; 2import { VirtualizedList } from 'react-virtual-dynamics'; 3 4const initialData = Array.from({ length: 200 }).map((_, i) => i + 1); 5 6const App = () => { 7 const [data, setData] = useState(initialData); 8 const [isLoading, setIsLoading] = useState(false); 9 10 const loadMore = () => { 11 if (!isLoading) { 12 setIsLoading(true); 13 setTimeout(() => { 14 const moreData = Array.from({ length: 20 }).map( 15 (_, i) => data.length + i + 1 16 ); 17 setData([...data, ...moreData]); 18 setIsLoading(false); 19 }, 1000); 20 } 21 }; 22 23 return ( 24 <VirtualizedList 25 dataLength={data.length} 26 viewportHeight={500} 27 gridColumns={4} 28 itemHeight={100} 29 gap={10} 30 loadMore={loadMore} 31 isLoading={isLoading} 32 renderItem={(index, style) => ( 33 <div key={index} style={style}> 34 {data[index]} 35 </div> 36 )} 37 /> 38 ); 39}; 40 41export default App;
1git clone https://github.com/muhammadumair12345/react-virtual-dynamics.git 2cd react-virtual-dynamics
1npm install
1npm run dev
To build the package, run:
1npm run build
This will create a dist
folder containing the compiled code.
1npx create-react-app my-app 2cd my-app 3npm install react-virtual-dynamics
VirtualizedList
component in your project as shown in the examples above.Contributions are welcome! Please follow these steps to contribute:
Please ensure your code follows the project's coding standards and passes all tests.
See the Contributing Guide for more details.
This project is licensed under the MIT License - see the LICENSE file for details.
Special thanks to the community for their contributions and feedback.
React-virtual-dynamics is designed to be a smaller, faster alternative to react-virtualized, with a more beginner-friendly API. If react-virtual-dynamics meets your needs, it is recommended over react-virtualized for most cases. However, if you need features specific to react-virtualized, you have two options:
Yes, by using the react-virtualized-auto-sizer package.
Ensure you are attaching the style parameter to the DOM elements you render. This is necessary for correct positioning.
Yes, use the loadMore prop to implement lazy loading.
Yes, although it requires inline styling.
Yes, although it requires inline styling.
Yes, with a bit of user code.
No vulnerabilities found.
No security vulnerabilities found.