Skip to content

Commit 39850f0

Browse files
authored
changed to check for document instead of window (#4688)
Fixes Remix SSR because deno supports window
1 parent ccb3737 commit 39850f0

File tree

6 files changed

+6
-6
lines changed

6 files changed

+6
-6
lines changed

packages/@react-aria/overlays/src/calculatePosition.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ const TOTAL_SIZE = {
101101
const PARSED_PLACEMENT_CACHE = {};
102102

103103
// @ts-ignore
104-
let visualViewport = typeof window !== 'undefined' && window.visualViewport;
104+
let visualViewport = typeof document !== 'undefined' && window.visualViewport;
105105

106106
function getContainerDimensions(containerNode: Element): Dimensions {
107107
let width = 0, height = 0, totalWidth = 0, totalHeight = 0, top = 0, left = 0;

packages/@react-aria/overlays/src/useOverlayPosition.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ export interface PositionAria {
7373
}
7474

7575
// @ts-ignore
76-
let visualViewport = typeof window !== 'undefined' && window.visualViewport;
76+
let visualViewport = typeof document !== 'undefined' && window.visualViewport;
7777

7878
/**
7979
* Handles positioning overlays like popovers and menus relative to a trigger

packages/@react-aria/overlays/src/usePreventScroll.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ interface PreventScrollOptions {
1818
}
1919

2020
// @ts-ignore
21-
const visualViewport = typeof window !== 'undefined' && window.visualViewport;
21+
const visualViewport = typeof document !== 'undefined' && window.visualViewport;
2222

2323
// HTML input types that do not cause the software keyboard to appear.
2424
const nonTextInputTypes = new Set([

packages/@react-aria/ssr/src/SSRProvider.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ function LegacySSRProvider(props: SSRProviderProps): JSX.Element {
6060

6161
// If on the client, and the component was initially server rendered,
6262
// then schedule a layout effect to update the component after hydration.
63-
if (typeof window !== 'undefined') {
63+
if (typeof document !== 'undefined') {
6464
// This if statement technically breaks the rules of hooks, but is safe
6565
// because the condition never changes after mounting.
6666
// eslint-disable-next-line react-hooks/rules-of-hooks

packages/@react-aria/utils/src/useLayoutEffect.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ import React from 'react';
1515
// During SSR, React emits a warning when calling useLayoutEffect.
1616
// Since neither useLayoutEffect nor useEffect run on the server,
1717
// we can suppress this by replace it with a noop on the server.
18-
export const useLayoutEffect = typeof window !== 'undefined'
18+
export const useLayoutEffect = typeof document !== 'undefined'
1919
? React.useLayoutEffect
2020
: () => {};

packages/@react-aria/utils/src/useViewportSize.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ interface ViewportSize {
1818
}
1919

2020
// @ts-ignore
21-
let visualViewport = typeof window !== 'undefined' && window.visualViewport;
21+
let visualViewport = typeof document !== 'undefined' && window.visualViewport;
2222

2323
export function useViewportSize(): ViewportSize {
2424
let [size, setSize] = useState(() => getViewportSize());

0 commit comments

Comments
 (0)