Skip to content

Commit

Permalink
fix(announcements): check if window is defined
Browse files Browse the repository at this point in the history
  • Loading branch information
aliceoq committed Feb 1, 2024
1 parent 956ec29 commit 2d456e6
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/pages/updates/announcements/[slug].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ const AnnouncementPage: NextPage<Props> = ({
}) => {
const intl = useIntl()
const [headings, setHeadings] = useState<Item[]>([])
const [url, setUrl] = useState('')
const { setBranchPreview } = useContext(PreviewContext)
setBranchPreview(branch)
const { setActiveSidebarElement } = useContext(LibraryContext)
Expand All @@ -87,6 +88,10 @@ const AnnouncementPage: NextPage<Props> = ({
setHeadings(headingList)
}, [serialized.frontmatter])

useEffect(() => {
if (window) setUrl(window.location.href)
}, [])

return (
<>
<Head>
Expand Down Expand Up @@ -117,7 +122,7 @@ const AnnouncementPage: NextPage<Props> = ({
</Text>
)}
</Box>
<ShareButton url={window.location.href} />
{url && <ShareButton url={url} />}
</Flex>
</header>
<MarkdownRenderer serialized={serialized} />
Expand Down

0 comments on commit 2d456e6

Please sign in to comment.