
Security News
NVD Concedes Inability to Keep Pace with Surging CVE Disclosures in 2025
Security experts warn that recent classification changes obscure the true scope of the NVD backlog as CVE volume hits all-time highs.
@react-aria/collections
Advanced tools
@react-aria/collections is a library that provides utilities for managing collections of items in React applications. It is part of the React Aria suite, which offers a set of hooks and components for building accessible user interfaces. This package helps with managing state and rendering lists, grids, and other collections of items.
useCollection
The `useCollection` hook helps manage a collection of items. It takes an array of items and a function to get the key for each item. The hook returns a collection that can be mapped over to render the items.
import { useCollection } from '@react-aria/collections';
const items = [
{ id: 1, name: 'Item 1' },
{ id: 2, name: 'Item 2' },
{ id: 3, name: 'Item 3' }
];
function MyComponent() {
const { collection } = useCollection({
items,
getKey: (item) => item.id
});
return (
<ul>
{collection.map(item => (
<li key={item.id}>{item.name}</li>
))}
</ul>
);
}
useListState
The `useListState` hook manages the state of a list of items. It takes an array of items and a function to get the key for each item. The hook returns a state object that includes the collection of items, which can be used to render the list.
import { useListState } from '@react-aria/collections';
const items = [
{ id: 1, name: 'Item 1' },
{ id: 2, name: 'Item 2' },
{ id: 3, name: 'Item 3' }
];
function MyComponent() {
const state = useListState({
items,
getKey: (item) => item.id
});
return (
<ul>
{state.collection.map(item => (
<li key={item.id}>{item.name}</li>
))}
</ul>
);
}
useGridState
The `useGridState` hook manages the state of a grid of items. It takes an array of items and a function to get the key for each item. The hook returns a state object that includes the collection of items, which can be used to render the grid.
import { useGridState } from '@react-aria/collections';
const items = [
{ id: 1, name: 'Item 1' },
{ id: 2, name: 'Item 2' },
{ id: 3, name: 'Item 3' }
];
function MyComponent() {
const state = useGridState({
items,
getKey: (item) => item.id
});
return (
<div role="grid">
{state.collection.map(item => (
<div role="row" key={item.id}>{item.name}</div>
))}
</div>
);
}
react-virtualized provides a set of components for efficiently rendering large lists and tabular data. It focuses on performance and offers features like lazy loading and infinite scrolling. Compared to @react-aria/collections, react-virtualized is more performance-oriented but does not focus on accessibility.
react-window is a lightweight library for rendering large lists and tabular data. It is similar to react-virtualized but with a smaller footprint and simpler API. Like react-virtualized, it focuses on performance rather than accessibility, making it different from @react-aria/collections.
downshift is a library for building accessible autocomplete, combobox, dropdown, and menu components. It provides utilities for managing state and rendering collections of items with a focus on accessibility. While it shares the accessibility focus with @react-aria/collections, downshift is more specialized in handling dropdowns and menus.
This package is part of react-spectrum. See the repo for more details.
FAQs
Spectrum UI components in React
The npm package @react-aria/collections receives a total of 467,730 weekly downloads. As such, @react-aria/collections popularity was classified as popular.
We found that @react-aria/collections 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
Security experts warn that recent classification changes obscure the true scope of the NVD backlog as CVE volume hits all-time highs.
Security Fundamentals
Attackers use obfuscation to hide malware in open source packages. Learn how to spot these techniques across npm, PyPI, Maven, and more.
Security News
Join Socket for exclusive networking events, rooftop gatherings, and one-on-one meetings during BSidesSF and RSA 2025 in San Francisco.