mrkeyoor.com_
Wed 23 Sept 00:33 UTC
npmWeb Frontendupdated 22 Sept 2026

react-virtualized-auto-sizer review

react-virtualized-auto-sizer observes the space inside a parent HTMLElement and gives numeric width and height values to a React child. That solves one specific integration problem for react-virtualized lists, canvases, grids, charts, and other widgets that cannot size themselves with CSS percentages. It measures layout and triggers updates; it does not virtualize records. Version 2 supports React 18 and 19, ResizeObserver box choices, a named AutoSizer export, and typed ChildComponent or renderProp APIs. The current 2.0.3 release changes only the README logo so it displays correctly in Firefox. Our package check found bundled types and successful require() and ESM imports.

Verdict

react-virtualized-auto-sizer 2.0.3 installed with 0 audit findings and measured 5.3 KB gzipped in our browser build, a reasonable cost when a pixel-sized child cannot observe its own parent. Skip it for current react-window or a layout that CSS already expresses.

We installed it

Lab card: what happened when we installed react-virtualized-auto-sizerScreenshot of react-virtualized-auto-sizer documentation
Install✓ · 1.5s4 packages on disk · 8 MB
ImportESM import works · require() works · ESM package
Browser5.3 KBgzipped (14.1 KB minified), bundled with esbuild
TypesTypeScript types bundled
Known vulns00 critical · 0 high · 0 moderate · 0 low (npm audit)

Answers from our run

Does react-virtualized-auto-sizer install cleanly?

Yes. In a fresh container with an empty cache, npm install react-virtualized-auto-sizer finished in 2 seconds, leaving 4 packages and 8 MB on disk. npm audit reported no known vulnerabilities.

How much does react-virtualized-auto-sizer add to a browser bundle?

5.3 KB gzipped (14.1 KB minified) when the whole package is bundled for the browser with esbuild. Importing only part of it is usually smaller.

Does react-virtualized-auto-sizer work with both ESM and CommonJS?

Yes. Both import 'react-virtualized-auto-sizer' and require('react-virtualized-auto-sizer') worked in Node 22 in our run. The package is published as ESM.

Does react-virtualized-auto-sizer include TypeScript types?

Yes, type declarations ship inside the package, so no @types install is needed.

react-virtualized-auto-sizer or react-window: which should you use?

react-window: Use its current built-in sizing when the real task is a new virtualized list or grid. react-virtualized-auto-sizer 2.0.3 installed with 0 audit findings and measured 5.3 KB gzipped in our browser build, a reasonable cost when a pixel-sized child cannot observe its own parent.

When should you not use react-virtualized-auto-sizer?

You use a recent react-window version; this package's README says react-window now observes its own size

API stability3/5The central contract still passes parent width and height into a child, but version 2 made a deliberate API break. It removed the children function, defaultWidth, defaultHeight, disableWidth, disableHeight, and doNotBailOutOnEmptyChildren, then split ChildComponent and renderProp in 2.0.1 while retaining Child as deprecated. The smaller current surface is typed and clear, yet 1.x callers need a migration rather than a version bump.
Docs5/5The README and live site document all 11 current props, the 3 ResizeObserver box choices, undefined initial and server dimensions, ChildComponent memoization, renderProp closure behavior, CSP nonce use, and the deprecation of Child. The 2.0.0 notes explain every removed prop with replacement code and disclose transition limits. Most importantly, the first README note says newer react-window releases already size themselves, preventing an unnecessary install.
Maintenance5/5Version 2.0.3 shipped on February 13, 2026 and GitHub shows a March 28 push. The repository is not archived and has 0 open issues or pull requests. The latest patch only repaired a Firefox README image, but the preceding 2.0 releases simplified the API and its TypeScript model. Recent 1.x work also covered React 19, multi-realm ResizeObserver lookup, padding, fractional rectangles, and browser behavior before the major release.
Ecosystem4/5npm recorded 3,361,886 downloads for the week ending August 24, 2026, and GitHub has 671 stars. The package comes from the author of react-virtualized and react-window, accepts React 18 and 19, and ships CommonJS, ESM, and declarations. Our install confirmed both loading styles. Demand is narrower now because current react-window contains its own observer and general ResizeObserver hooks fit arbitrary element measurement better.

Use it if

  • react-virtualized or another widget requires numeric pixel width and height props
  • A canvas, grid, chart, or WebGL surface must follow its container instead of the viewport
  • ResizeObserver box selection and a fallback for old browsers belong behind one component
  • The project is on React 18 or 19 and wants declarations bundled with the sizing component
Skip it if

Setup reality

Our fresh install of react-virtualized-auto-sizer 2.0.3 finished in 1.5 seconds on Node 22. It left 4 packages consuming 8 MB, and npm audit reported 0 known vulnerabilities. The package itself is 108 KB unpacked with 0 direct dependencies and 2 peers, React and React DOM 18 or 19. It is marked ESM without an exports map; require() and ESM import both worked, and types are bundled. Our browser import measured 14.1 KB minified and 5.3 KB gzipped.

No credential or config file is involved. CSS causes most failures: AutoSizer measures its parent but does not give that parent a size. Set a real block height or a bounded flex or grid track. In flex layouts, a dedicated flex: 1 1 auto child plus min-width: 0 or min-height: 0 often supplies the measurable box. ChildComponent gets better memoization when it is defined outside the parent; renderProp is intended for code that must close over local state.

Both dimensions are undefined during the initial render, including SSR. The v2 API drops defaultWidth and defaultHeight; put estimates in the child function's default parameters or show a placeholder until both values exist. disableWidth and disableHeight are gone as well. React.memo with a comparator that watches only width or height is the replacement. content-box is the default observation mode; border-box includes padding and borders, while device-pixel-content-box depends on browser support and is useful mainly for high-density drawing surfaces.

ResizeObserver callbacks are scheduled through a 0-delay timer to avoid loop-limit errors. Browsers without ResizeObserver use a legacy element-resize path that injects styles, so strict Content Security Policy setups may need the nonce prop. jsdom has no layout engine; tests must stub ResizeObserver and parent rectangles instead of expecting a measured size. CSS transforms and transitions can produce intermediate readings, with no completion event. Version 2.0.3 has no runtime behavior change; its sole release note is the Firefox README-logo fix.

Patterns

Measure a parent with fixed height measure-parent

import { AutoSizer, type SizeProps } from 'react-virtualized-auto-sizer'

function CanvasSurface({ width, height }: SizeProps) {
  if (width === undefined || height === undefined) return null
  return <canvas width={width} height={height} />
}

export function Panel() {
  return (
    <div style={{ width: '100%', height: 400 }}>
      <AutoSizer ChildComponent={CanvasSurface} />
    </div>
  )
}

The parent has an explicit 400-pixel height. AutoSizer cannot infer dimensions from an unbounded or zero-height container.

Close over chart state with renderProp use-render-prop

function ChartPanel({ points }) {
  const [highlight, setHighlight] = useState(null)
  return (
    <AutoSizer
      renderProp={({ width, height }) =>
        width === undefined || height === undefined ? null : (
          <Chart width={width} height={height} points={points}
            highlight={highlight} onHighlight={setHighlight} />
        )
      }
    />
  )
}

renderProp can read local state. A module-level ChildComponent is easier for AutoSizer to memoize when closure state is unnecessary.

Feed dimensions into react-virtualized size-virtualized-list

function SizedList({ width, height }: SizeProps) {
  if (width === undefined || height === undefined) return null
  return <List width={width} height={height} rowCount={rows.length}
    rowHeight={36} rowRenderer={rowRenderer} />
}

<div style={{ height: 500 }}>
  <AutoSizer ChildComponent={SizedList} />
</div>

This pattern targets react-virtualized and other explicit-size widgets. Recent react-window versions do not require AutoSizer.

Default the first server dimensions provide-ssr-estimate

function ResultsGrid({
  width = 800,
  height = 600,
}: SizeProps) {
  return <Grid width={width} height={height} />
}

<AutoSizer ChildComponent={ResultsGrid} />

The v2 component no longer accepts defaultWidth or defaultHeight. Pick the 800 by 600 estimate to limit hydration movement for the actual layout.

Wait for the first measurement show-placeholder

function MeasuredChart({ width, height }: SizeProps) {
  if (width === undefined || height === undefined) {
    return <ChartSkeleton />
  }
  return <Chart width={width} height={height} />
}

Initial client and server values are undefined. Check that specifically because 0 is a valid measured dimension.

Bound a flex measurement area measure-flex-child

<div style={{ display: 'flex', width: '100%', height: '100%' }}>
  <Sidebar />
  <div style={{ flex: '1 1 auto', minWidth: 0, minHeight: 0 }}>
    <AutoSizer ChildComponent={ResultsGrid} />
  </div>
</div>

The dedicated flex child grows to the remaining area. Both 0 minimums prevent intrinsic content from forcing overflow.

Update only for height changes ignore-width

const HeightOnly = memo(
  function HeightOnly({ height }: SizeProps) {
    return <Timeline height={height ?? 0} />
  },
  (previous, next) => previous.height === next.height,
)

<AutoSizer ChildComponent={HeightOnly} />

The old disableWidth and disableHeight props are absent from v2. React.memo suppresses the child render, though AutoSizer still observes both dimensions.

Include padding and borders measure-border-box

<AutoSizer
  box="border-box"
  ChildComponent={CanvasSurface}
/>

content-box is the default. border-box gives the child the parent's outer box dimensions including padding and borders.

Request physical canvas pixels measure-device-pixels

<AutoSizer
  box="device-pixel-content-box"
  ChildComponent={HiDpiCanvas}
/>

device-pixel-content-box support differs among browsers. Test the supported set and keep a content-box fallback.

Record parent-size changes observe-resize

<AutoSizer
  ChildComponent={ResultsGrid}
  onResize={({ width, height }) => {
    metrics.record('results-grid-size', { width, height })
  }}
/>

A transition can produce many callbacks and has no final-completion event. Rate-limit analytics or persistence outside AutoSizer.

Permit fallback styles under CSP set-csp-nonce

<AutoSizer
  nonce={cspNonce}
  ChildComponent={ResultsGrid}
/>

The nonce applies to the injected legacy resize stylesheet. A browser using ResizeObserver does not need that fallback style.

Replace the v1 children function migrate-v1

// Version 1:
// <AutoSizer>{({ width, height }) => <Grid width={width} height={height} />}</AutoSizer>

// Version 2:
<AutoSizer
  renderProp={({ width = 800, height = 600 }) => (
    <Grid width={width} height={height} />
  )}
/>

Version 2 moves the render callback to renderProp and initial estimates to the callback's default parameters.

Alternatives

PackageRegistryPick it when
react-windownpmUse its current built-in sizing when the real task is a new virtualized list or grid
react-use-measurenpmUse it when a hook and ref should observe any existing element
react-resize-detectornpmUse it when hook and component forms with debounce or throttle options are useful
@react-hook/resize-observernpmUse it for a narrow hook around observing an element ref

More web frontend guides

postcss · react · react-dom · tailwindcss · htmlparser2 · tailwind-merge · the whole shelf →

How this guide is made: grounded in the library's documentation, release notes, changelog, and issue history, on a fixed rubric — not a hands-on install of every release. The 50 most-downloaded entries are additionally install-verified in clean containers. Corrections: contact the desk.