🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

@react-aria/virtualizer

Package Overview
Dependencies
Maintainers
2
Versions
1033
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@react-aria/virtualizer

Spectrum UI components in React

4.1.6
Source
npm
Version published
Weekly downloads
594K
-0.82%
Maintainers
2
Weekly downloads
 
Created

What is @react-aria/virtualizer?

@react-aria/virtualizer is a library that provides utilities for efficiently rendering large lists and collections in React applications. It leverages virtualization techniques to only render the visible items, improving performance and reducing memory usage.

What are @react-aria/virtualizer's main functionalities?

Virtualized List

This feature allows you to create a virtualized list where only the visible items are rendered. This improves performance for large lists by reducing the number of DOM elements.

import { useVirtualizer } from '@react-aria/virtualizer';
import { useRef } from 'react';

function VirtualizedList({ items }) {
  const parentRef = useRef();
  const { virtualItems, totalSize } = useVirtualizer({
    count: items.length,
    getScrollElement: () => parentRef.current,
    estimateSize: () => 35
  });

  return (
    <div ref={parentRef} style={{ overflow: 'auto', height: '400px' }}>
      <div style={{ height: totalSize }}>
        {virtualItems.map(virtualRow => (
          <div
            key={virtualRow.index}
            style={{
              position: 'absolute',
              top: 0,
              left: 0,
              width: '100%',
              transform: `translateY(${virtualRow.start}px)`
            }}
          >
            {items[virtualRow.index]}
          </div>
        ))}
      </div>
    </div>
  );
}

Virtualized Grid

This feature allows you to create a virtualized grid where only the visible items are rendered. This is useful for displaying large grids of items efficiently.

import { useVirtualizer } from '@react-aria/virtualizer';
import { useRef } from 'react';

function VirtualizedGrid({ items, columnCount }) {
  const parentRef = useRef();
  const { virtualItems, totalSize } = useVirtualizer({
    count: items.length,
    getScrollElement: () => parentRef.current,
    estimateSize: () => 100
  });

  return (
    <div ref={parentRef} style={{ overflow: 'auto', height: '400px' }}>
      <div style={{ height: totalSize }}>
        {virtualItems.map(virtualItem => (
          <div
            key={virtualItem.index}
            style={{
              position: 'absolute',
              top: 0,
              left: 0,
              width: `${100 / columnCount}%`,
              transform: `translate(${(virtualItem.index % columnCount) * 100}%, ${Math.floor(virtualItem.index / columnCount) * 100}px)`
            }}
          >
            {items[virtualItem.index]}
          </div>
        ))}
      </div>
    </div>
  );
}

Other packages similar to @react-aria/virtualizer

FAQs

Package last updated on 05 Jun 2025

Did you know?

Socket

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.

Install

Related posts