From a5b2526177b34f120a66757f8b9e1cf9b4056b7d Mon Sep 17 00:00:00 2001 From: Sara Date: Tue, 26 Sep 2023 13:08:35 +0200 Subject: [PATCH] Fix window not defined error --- www/app/transcripts/shareLink.tsx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/www/app/transcripts/shareLink.tsx b/www/app/transcripts/shareLink.tsx index ee7882e8..912f1e8b 100644 --- a/www/app/transcripts/shareLink.tsx +++ b/www/app/transcripts/shareLink.tsx @@ -1,10 +1,13 @@ -import React, { useState, useRef } from "react"; +import React, { useState, useRef, useEffect, use } from "react"; const ShareLink = () => { const [isCopied, setIsCopied] = useState(false); const inputRef = useRef(null); + const [currentUrl, setCurrentUrl] = useState(); - const currentURL = window.location.href; + useEffect(() => { + setCurrentUrl(window.location.href); + }, []); const handleCopyClick = () => { if (inputRef.current) { @@ -31,7 +34,7 @@ const ShareLink = () => {