Releases: bvaughn/react-window
Releases · bvaughn/react-window
2.0.2
2.0.1
- Remove ARIA
role
attribute fromList
andGrid
. This resulted in potentially invalid configurations (e.g. a ARIA list should contain at least one listitem but that was not enforced by this library). Users of this library should specify therole
attribute that makes the most sense to them based on mdn guidelines. For example:
<List
role="list"
rowComponent={RowComponent}
rowCount={names.length}
rowHeight={25}
rowProps={{ names }}
/>;
function RowComponent({ index, style, ...rest }: RowComponentProps<object>) {
return (
<div role="listitem" style={style}>
...
</div>
);
}
2.0.0
Version 2 is a major rewrite that offers the following benefits:
- More ergonomic props API
- Automatic memoization of row/cell renderers and props/context
- Automatically sizing for
List
andGrid
(no more need forAutoSizer
) - Native TypeScript support (no more need for
@types/react-window
) - Smaller bundle size
Upgrade path
See the documentation for more details, but here is an example of what the v1 to v2 upgrade might look like:
Before
import { FixedSizeList, type ListChildComponentProps } from "react-window";
function Example({ names }: { names: string[] }) {
const itemData = useMemo<ItemData>(() => ({ names }), [names]);
return (
<FixedSizeList
children={Row}
height={150}
itemCount={1000}
itemData={itemData}
itemSize={25}
width={300}
/>
);
}
function Row({
data,
index,
style
}: ListChildComponentProps<{
names: string[];
}>) {
const { names } = data;
const name = names[index];
return <div style={style}>{name}</div>;
}
After
import { List, type RowComponentProps } from "react-window";
function Example({ names }: { names: string[] }) {
return (
<List
rowComponent={RowComponent}
rowCount={names.length}
rowHeight={25}
rowProps={{ names }}
/>
);
}
function RowComponent({
index,
names,
style
}: RowComponentProps<{
names: string[];
}>) {
const name = names[index];
return <div style={style}>{name}</div>;
}
⚠️ Version 2 requirements
The following requirements are new in version 2 and may be reasons to consider not upgrading:
- Peer dependencies now require React version 18 or newer
ResizeObserver
primitive (or polyfill) is required unless explicit pixel dimensions are provided viastyle
prop; (see documentation for more)
1.8.11
1.8.10
1.8.9
1.3.1
1.2.1
1.2.0
- Remove
overflow:hidden
from inner container (souporserious - #56) - 🎉 Flow types added to NPM package. (TrySound - #40)
- 🎉 Relaxed grid
scrollTo
method to makescrollLeft
andscrollTop
params optional (so you can only update one axis if desired). - #63) - 🐛 Fixed invalid
this
pointer inVariableSizeGrid
that broke theresetAfter*
methods - #58)