Skip to content

Commit f521fb7

Browse files
authored
fix: sever env detection for deno (#4064)
1 parent 2684b72 commit f521fb7

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/_internal/utils/env.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import React, { useEffect, useLayoutEffect } from 'react'
2-
import { hasRequestAnimationFrame, isWindowDefined } from './helper'
2+
import { hasRequestAnimationFrame, isLegacyDeno, isWindowDefined } from './helper'
33

44
export const IS_REACT_LEGACY = !React.useId
55

6-
export const IS_SERVER = !isWindowDefined || 'Deno' in globalThis
6+
export const IS_SERVER = !isWindowDefined || isLegacyDeno
77

88
// Polyfill requestAnimationFrame
99
export const rAF = (

src/_internal/utils/helper.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ const STR_UNDEFINED = 'undefined'
1010
// NOTE: Use the function to guarantee it's re-evaluated between jsdom and node runtime for tests.
1111
export const isWindowDefined = typeof window != STR_UNDEFINED
1212
export const isDocumentDefined = typeof document != STR_UNDEFINED
13+
export const isLegacyDeno = isWindowDefined && 'Deno' in window
14+
1315
export const hasRequestAnimationFrame = () =>
1416
isWindowDefined && typeof window['requestAnimationFrame'] != STR_UNDEFINED
1517

0 commit comments

Comments
 (0)