Skip to content

Commit

Permalink
CopyToClipboard: Don't crash in Gatsby's server side rendering
Browse files Browse the repository at this point in the history
See gatsbyjs/gatsby#19317 - even attempting to
reference "navigator" directly will throw an error.

In passing fix whitespace issue in directory.json.
  • Loading branch information
lfittl committed Dec 14, 2023
1 parent 064e813 commit b4fd86b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion components/CopyToClipboard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const CopyToClipboard: React.FunctionComponent<Props> = ({
const [copied, setCopied] = useState(false);
const [waitingForContent, setWaitingForContent] = useState(false);
const [copyError, setCopyError] = useState(null);
const { clipboard } = navigator;
const { clipboard } = typeof navigator === 'object' && navigator;
if (!clipboard) {
return null;
}
Expand Down
2 changes: 1 addition & 1 deletion directory.json
Original file line number Diff line number Diff line change
Expand Up @@ -2397,4 +2397,4 @@
"app-errors": "Application / User Errors",
"unknown": "Unknown Events"
}
}
}

0 comments on commit b4fd86b

Please sign in to comment.