From 2247a514bcd07cc4b67f1167b51ccbec0bf78426 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikolas=20Schr=C3=B6ter?= <25958801+nwidynski@users.noreply.github.com> Date: Mon, 1 Sep 2025 07:50:24 +0200 Subject: [PATCH] fix: @react-stately/virtualizer dependencies (#8724) * fix: remove react-aria dependency * chore: update package.json * update yarn.lock --------- Co-authored-by: Daniel Lu --- packages/@react-stately/virtualizer/package.json | 1 - .../virtualizer/src/useVirtualizerState.ts | 10 ++++++++-- yarn.lock | 1 - 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/packages/@react-stately/virtualizer/package.json b/packages/@react-stately/virtualizer/package.json index ca4f077cd28..2dc1fef8278 100644 --- a/packages/@react-stately/virtualizer/package.json +++ b/packages/@react-stately/virtualizer/package.json @@ -26,7 +26,6 @@ "url": "https://github.com/adobe/react-spectrum" }, "dependencies": { - "@react-aria/utils": "^3.30.1", "@react-types/shared": "^3.32.0", "@swc/helpers": "^0.5.0" }, diff --git a/packages/@react-stately/virtualizer/src/useVirtualizerState.ts b/packages/@react-stately/virtualizer/src/useVirtualizerState.ts index 9844e2acdd0..dfa5181991e 100644 --- a/packages/@react-stately/virtualizer/src/useVirtualizerState.ts +++ b/packages/@react-stately/virtualizer/src/useVirtualizerState.ts @@ -13,13 +13,19 @@ import {Collection, Key} from '@react-types/shared'; import {InvalidationContext} from './types'; import {Layout} from './Layout'; +import React, {useCallback, useMemo, useRef, useState} from 'react'; import {Rect} from './Rect'; import {ReusableView} from './ReusableView'; import {Size} from './Size'; -import {useCallback, useMemo, useRef, useState} from 'react'; -import {useLayoutEffect} from '@react-aria/utils'; import {Virtualizer} from './Virtualizer'; +// During SSR, React emits a warning when calling useLayoutEffect. +// Since neither useLayoutEffect nor useEffect run on the server, +// we can suppress this by replace it with a noop on the server. +export const useLayoutEffect: typeof React.useLayoutEffect = typeof document !== 'undefined' + ? React.useLayoutEffect + : () => {}; + interface VirtualizerProps { renderView(type: string, content: T | null): V, layout: Layout, diff --git a/yarn.lock b/yarn.lock index 1c770a5f681..ee1fcc75171 100644 --- a/yarn.lock +++ b/yarn.lock @@ -8390,7 +8390,6 @@ __metadata: version: 0.0.0-use.local resolution: "@react-stately/virtualizer@workspace:packages/@react-stately/virtualizer" dependencies: - "@react-aria/utils": "npm:^3.30.1" "@react-types/shared": "npm:^3.32.0" "@swc/helpers": "npm:^0.5.0" peerDependencies: