diff --git a/contributors.yml b/contributors.yml index c11fb3b3030..8ee508fe9d3 100644 --- a/contributors.yml +++ b/contributors.yml @@ -69,6 +69,7 @@ - atesgoral - athongsavath - AustinGil +- avindra - awthwathje - axel-habermaier - baby230211 diff --git a/docs/guides/gotchas.md b/docs/guides/gotchas.md index 2e7ae4b208c..0b5e9f45171 100644 --- a/docs/guides/gotchas.md +++ b/docs/guides/gotchas.md @@ -8,30 +8,6 @@ Rendering your app on the server and in the browser with React has some inherent This document should help you get over these bumps. -## `typeof window` checks - -Because the same JavaScript code can run in the browser as well as the server, sometimes you need to have a part of your code that only runs in one context or the other: - -```ts bad -if (typeof window === "undefined") { - // running in a server environment -} else { - // running in a browser environment -} -``` - -This works fine in a Node.js environment, however, Deno actually supports `window`! So if you really want to check whether you're running in the browser, it's better to check for `document` instead: - -```ts good -if (typeof document === "undefined") { - // running in a server environment -} else { - // running in a browser environment -} -``` - -This will work for all JS environments (Node.js, Deno, Workers, etc.). - ## Browser extensions injecting code You may run into this warning in the browser: