Skip to content

Commit

Permalink
Merge pull request #3446 from tillhainbach/fix-ssr
Browse files Browse the repository at this point in the history
Fix `ReferenceError: window is undefined` Server-Side-Rendering
  • Loading branch information
quantizor committed Mar 31, 2021
2 parents bdde5e2 + d8f7b05 commit 06afb1b
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/styled-components/src/utils/nonce.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@
declare var window: { __webpack_nonce__: string };

const getNonce = () => {
return typeof window.__webpack_nonce__ !== 'undefined' ? window.__webpack_nonce__ : null;

return typeof window !== 'undefined'
? typeof window.__webpack_nonce__ !== 'undefined'
? window.__webpack_nonce__
: null
: null;
};

export default getNonce;

0 comments on commit 06afb1b

Please sign in to comment.