Gathering detailed insights and metrics for react-dynamic-window
Gathering detailed insights and metrics for react-dynamic-window
Gathering detailed insights and metrics for react-dynamic-window
Gathering detailed insights and metrics for react-dynamic-window
@john-osullivan/react-window-dynamic-fork
Temporary Fork: see https://github.com/bvaughn/react-window
react-viewport-list
📜 Virtualization for lists with dynamic item size
react-window-dynamic-list
A naive approach for virtualizing a list with dynamically sized items
react-window-dynamic
React components for efficiently rendering large, scrollable lists and tabular data
React virtualization library for efficiently rendering large scrollable lists with dynamic heights and expandable content.
npm install react-dynamic-window
Typescript
Module System
Node Version
NPM Version
1.0.7 (January 2, 2025)
Updated on Jan 01, 2025
1.0.6 (December 29, 2024)
Updated on Dec 28, 2024
1.0.5 (December 23, 2024)
Updated on Dec 22, 2024
1.0.4 (December 22, 2024)
Updated on Dec 21, 2024
1.0.3 (December 21, 2024)
Updated on Dec 21, 2024
1.0.2 (December 21, 2024)
Updated on Dec 21, 2024
TypeScript (87.42%)
CSS (7.84%)
JavaScript (4.01%)
HTML (0.73%)
Total Downloads
747
Last Day
1
Last Week
4
Last Month
40
Last Year
747
1 Stars
26 Commits
1 Watchers
1 Branches
1 Contributors
Updated on Mar 30, 2025
Minified
Minified + Gzipped
Latest Version
1.0.7
Package Id
react-dynamic-window@1.0.7
Unpacked Size
487.62 kB
Size
395.06 kB
File Count
7
NPM Version
11.0.0
Node Version
23.4.0
Published on
Jan 01, 2025
Cumulative downloads
Total Downloads
Last Day
0%
1
Compared to previous day
Last Week
-73.3%
4
Compared to previous week
Last Month
-11.1%
40
Compared to previous month
Last Year
0%
747
Compared to previous year
28
React virtualization library for efficiently rendering large scrollable lists with dynamic heights and expandable content.
Check out the live demo: https://rdw.surge.sh/
1npm install react-dynamic-window 2# or 3yarn add react-dynamic-window 4# or 5pnpm add react-dynamic-window
1import { ReactDynamicWindow } from 'react-dynamic-window'; 2 3function App() { 4 const items = Array.from({ length: 1000 }, (_, i) => ({ 5 id: i, 6 title: `Item ${i}`, 7 content: `Content for item ${i}`, 8 })); 9 10 return ( 11 <div style={{ width: '500px', height: '600px' }}> 12 <ReactDynamicWindow 13 className="list-item" 14 data={items} 15 itemHeight={150} 16 bufferSize={4} 17 onLoadMore={() => { 18 // Load more items 19 }} 20 > 21 {({ data, isExpanded, onClick }) => ( 22 <div onClick={onClick}> 23 <h3>{data.title}</h3> 24 {isExpanded && <p>{data.content}</p>} 25 </div> 26 )} 27 </ReactDynamicWindow> 28 </div> 29 ); 30}
Prop | Type | Default | Description |
---|---|---|---|
data | T[] | Required | Array of items to render |
itemHeight | number | 150 | Default height for each item (10-1000px) |
bufferSize | number | 4 | Number of items to render outside viewport (1-20) |
threshold | number | 0.9 | Scroll threshold for loading more items (0.1-1.0) |
className | string | - | Custom CSS class for list items |
hasLatestData | boolean | - | Indicates if latest data is available |
controls | ReactDynamicWindowControls | - | External controls for scroll management |
onLoadMore | () => void | Required | Callback when more items needed |
onLoadLatest | () => Promise<boolean> | - | Callback to load latest items |
The library automatically handles dynamic heights using ResizeObserver, making it perfect for expandable content:
1<ReactDynamicWindow data={items}> 2 {({ data, isExpanded }) => ( 3 <div> 4 <h3>{data.title}</h3> 5 {isExpanded && ( 6 <div className="expandable-content"> 7 <img src={data.image} alt={data.title} loading="lazy" /> 8 <p>{data.description}</p> 9 </div> 10 )} 11 </div> 12 )} 13</ReactDynamicWindow>
You can control the scroll behavior externally using the controls prop:
1const controls = { 2 scrollToTop: () => () => void, 3 // First function (provided by component) handles the scroll behavior 4 // Second function (user-defined) can be used for custom actions 5}; 6 7<ReactDynamicWindow 8 controls={controls} 9 data={items} 10> 11 {/* ... */} 12</ReactDynamicWindow> 13 14// Later in your code 15const scrollFn = controls.scrollToTop({ behavior: 'smooth' }); 16scrollFn(); // Execute the returned function
The component supports infinite scrolling in both directions: loading more items when scrolling down and loading latest items when scrolling to top.
1<ReactDynamicWindow 2 data={items} 3 hasLatestData={hasNewItems} // Flag indicating new items are available 4 onLoadMore={handleLoadMore} // Called when scrolling down 5 onLoadLatest={handleLoadLatest} // Called when scrolling to top 6> 7 {({ data }) => <ListItem data={data} />} 8</ReactDynamicWindow>
Key concepts:
hasLatestData
: Indicates whether new items are available at the toponLoadLatest
: Triggered only when scrolling to top AND hasLatestData
is truetrue
from onLoadLatest
if new items were loaded, false
otherwiseTypical use cases:
The component accepts a className prop and provides full control over item styling:
1<ReactDynamicWindow className="custom-list-item" data={items}> 2 {({ data, isExpanded }) => ( 3 <div className={`item ${isExpanded ? 'expanded' : ''}`}> 4 {/* Your custom item content */} 5 </div> 6 )} 7</ReactDynamicWindow>
Contributions are welcome! Please feel free to submit a Pull Request.
git checkout -b feature/AmazingFeature
)git commit -m 'Add some AmazingFeature'
)git push origin feature/AmazingFeature
)📝 MIT © [MNIII]
No vulnerabilities found.
No security vulnerabilities found.