mirror of
https://github.com/Monadical-SAS/reflector.git
synced 2025-12-21 04:39:06 +00:00
Fix window not defined error
This commit is contained in:
@@ -1,10 +1,13 @@
|
|||||||
import React, { useState, useRef } from "react";
|
import React, { useState, useRef, useEffect, use } from "react";
|
||||||
|
|
||||||
const ShareLink = () => {
|
const ShareLink = () => {
|
||||||
const [isCopied, setIsCopied] = useState(false);
|
const [isCopied, setIsCopied] = useState(false);
|
||||||
const inputRef = useRef<HTMLInputElement>(null);
|
const inputRef = useRef<HTMLInputElement>(null);
|
||||||
|
const [currentUrl, setCurrentUrl] = useState<string>();
|
||||||
|
|
||||||
const currentURL = window.location.href;
|
useEffect(() => {
|
||||||
|
setCurrentUrl(window.location.href);
|
||||||
|
}, []);
|
||||||
|
|
||||||
const handleCopyClick = () => {
|
const handleCopyClick = () => {
|
||||||
if (inputRef.current) {
|
if (inputRef.current) {
|
||||||
@@ -31,7 +34,7 @@ const ShareLink = () => {
|
|||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
readOnly
|
readOnly
|
||||||
value={currentURL}
|
value={currentUrl}
|
||||||
ref={inputRef}
|
ref={inputRef}
|
||||||
className="border rounded-lg md:rounded-xl p-2 flex-grow mr-2 text-sm bg-slate-100 outline-slate-400"
|
className="border rounded-lg md:rounded-xl p-2 flex-grow mr-2 text-sm bg-slate-100 outline-slate-400"
|
||||||
/>
|
/>
|
||||||
|
|||||||
Reference in New Issue
Block a user