Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
react-window
Advanced tools
React components for efficiently rendering large, scrollable lists and tabular data
The react-window npm package is a React component library that provides efficient rendering of large lists and tabular data. It works by only rendering the items that are currently visible within the viewport, which can significantly improve the performance of applications that need to display large amounts of data.
Fixed Size List
This feature allows you to render a list where each item has a fixed size. The FixedSizeList component requires you to specify the height and width of the list container, the number of items, and the size of each item.
import { FixedSizeList } from 'react-window';
function App() {
return (
<FixedSizeList
height={150}
itemCount={1000}
itemSize={35}
width={300}
>
{({ index, style }) => <div style={style}>Row {index}</div>}
</FixedSizeList>
);
}
Variable Size List
This feature is similar to the FixedSizeList but allows for items with variable sizes. The VariableSizeList component requires an itemSize function that returns the size of an item given its index.
import { VariableSizeList } from 'react-window';
const rowHeights = new Array(1000).fill(true).map(() => 25 + Math.round(Math.random() * 50));
function App() {
return (
<VariableSizeList
height={150}
itemCount={1000}
itemSize={index => rowHeights[index]}
width={300}
>
{({ index, style }) => <div style={style}>Row {index}</div>}
</VariableSizeList>
);
}
Fixed Size Grid
The FixedSizeGrid component allows you to render a grid (or table) where each cell has a fixed size. You need to specify the dimensions of the grid, the size of each cell, and the number of rows and columns.
import { FixedSizeGrid } from 'react-window';
function App() {
return (
<FixedSizeGrid
columnCount={100}
columnWidth={100}
height={150}
rowCount={1000}
rowHeight={35}
width={300}
>
{({ columnIndex, rowIndex, style }) => <div style={style}>Cell {rowIndex},{columnIndex}</div>}
</FixedSizeGrid>
);
}
Variable Size Grid
The VariableSizeGrid component is used for rendering a grid where the size of cells can vary. It requires functions to determine the height of rows and the width of columns based on their indices.
import { VariableSizeGrid } from 'react-window';
const columnWidths = new Array(100).fill(true).map(() => 75 + Math.round(Math.random() * 50));
const rowHeights = new Array(1000).fill(true).map(() => 25 + Math.round(Math.random() * 50));
function App() {
return (
<VariableSizeGrid
columnCount={100}
columnWidth={index => columnWidths[index]}
height={150}
rowCount={1000}
rowHeight={index => rowHeights[index]}
width={300}
>
{({ columnIndex, rowIndex, style }) => <div style={style}>Cell {rowIndex},{columnIndex}</div>}
</VariableSizeGrid>
);
}
React-virtualized is another popular library for efficiently rendering large lists and tabular data in React applications. It offers a similar set of features to react-window but includes additional functionality such as cell measuring and dynamic grid layouts. However, react-window is often preferred for its simpler API and better performance in common use cases.
React-infinite is a package that helps in building infinite scrolling lists in React. It differs from react-window in that it focuses on providing an infinite scrolling experience rather than just windowing. React-infinite may be more suitable for use cases where the list length is not known upfront or can grow dynamically.
React-list is a versatile infinite scroll React component. It supports variable lengths, dynamic item sizes, horizontal layouts, and more. Compared to react-window, react-list has a more flexible API but may not be as optimized for performance in rendering large datasets.
React components for efficiently rendering large lists and tabular data
# Yarn
yarn add react-window
# NPM
npm install --save react-window
Learn more at react-window.now.sh.
MIT © bvaughn
1.0.1
Updated README.md
file to remove @alpha
tag from NPM installation instructions.
Initial release of library. Includes the following components:
FixedSizeGrid
FixedSizeList
VariableSizeGrid
VariableSizeList
FAQs
React components for efficiently rendering large, scrollable lists and tabular data
The npm package react-window receives a total of 1,254,639 weekly downloads. As such, react-window popularity was classified as popular.
We found that react-window demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
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.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.