JedWatson / JedWatson/react-select

ReferenceError: 'window' is not defined at... var globalContext = isBrowser ? window : global;

Open
#4,722 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

awaiting-author-response issue/bug-unconfirmed
Dominant language
TypeScript
Stars
28k
Forks
4.1k
PR merge metrics
No merged PRs in 30d

Description

Very simple. I can this error ReferenceError: 'window' is not defined at line:
var globalContext = isBrowser ? window : global

window object does not exist on server so error is thrown.

Rendering on client works fine!

Are you reporting a bug or runtime error?

Runtime error

I cannot use codepen! Problem is when rendering on server!

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the reported line, var globalContext = isBrowser ? window : global, and trace how it is reached during server rendering. Reproduce the error in a server-rendering setup, then verify that the issue no longer raises ReferenceError: 'window' is not defined while client rendering continues to work.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript
Domain
frontend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.