Skip to content

Commit

Permalink
fix: sever env detection for deno (#4064)
Browse files Browse the repository at this point in the history
  • Loading branch information
elrrrrrrr authored Jan 10, 2025
1 parent 2684b72 commit f521fb7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/_internal/utils/env.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React, { useEffect, useLayoutEffect } from 'react'
import { hasRequestAnimationFrame, isWindowDefined } from './helper'
import { hasRequestAnimationFrame, isLegacyDeno, isWindowDefined } from './helper'

export const IS_REACT_LEGACY = !React.useId

export const IS_SERVER = !isWindowDefined || 'Deno' in globalThis
export const IS_SERVER = !isWindowDefined || isLegacyDeno

// Polyfill requestAnimationFrame
export const rAF = (
Expand Down
2 changes: 2 additions & 0 deletions src/_internal/utils/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ const STR_UNDEFINED = 'undefined'
// NOTE: Use the function to guarantee it's re-evaluated between jsdom and node runtime for tests.
export const isWindowDefined = typeof window != STR_UNDEFINED
export const isDocumentDefined = typeof document != STR_UNDEFINED
export const isLegacyDeno = isWindowDefined && 'Deno' in window

export const hasRequestAnimationFrame = () =>
isWindowDefined && typeof window['requestAnimationFrame'] != STR_UNDEFINED

Expand Down

0 comments on commit f521fb7

Please sign in to comment.