Skip to content

Commit

Permalink
fix(hooks): add window definition guard to NewWindowContext
Browse files Browse the repository at this point in the history
  • Loading branch information
ivangabriele committed Nov 21, 2024
1 parent 8e1f993 commit d75f6d4
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/hooks/useNewWindow/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ import type { NewWindowContextValue } from './types'

export const NewWindowContext = createContext<NewWindowContextValue>({
newWindowContainerRef: {
current: window.document.createElement('div')
// It seems monitor-ui bundle can eager-evaluate `NewWindowContext`
// in contexts which don't have `window` global defined.
// This any-forced `undefined` should never impact the real webapp initialization.
current: typeof window !== 'undefined' ? window.document.createElement('div') : (undefined as any)
}
})

0 comments on commit d75f6d4

Please sign in to comment.