diff --git a/src/components/button-share/button-share.tsx b/src/components/button-share/button-share.tsx index bb3ef53fa..ef3dd5b34 100644 --- a/src/components/button-share/button-share.tsx +++ b/src/components/button-share/button-share.tsx @@ -18,7 +18,7 @@ const ButtonShare: React.FC = ({ className }) => { const copyButtonAreaLabel = "Copy this page to clipboard"; const [showFixedButtons, setShowFixedButtons] = useState(true); - const shareButton = useRef(null); + const shareButtonRef = useRef(null); const onShareButtonClick = () => { navigator.clipboard.writeText(href); @@ -38,13 +38,15 @@ const ButtonShare: React.FC = ({ className }) => { { threshold: 1 } ); - if (shareButton.current) { - observer.observe(shareButton.current); + const shareButton = shareButtonRef.current; + + if (shareButton) { + observer.observe(shareButton); } return () => { - if (shareButton.current) { - observer.unobserve(shareButton.current); + if (shareButton) { + observer.unobserve(shareButton); } }; }, []); @@ -71,7 +73,7 @@ const ButtonShare: React.FC = ({ className }) => { )}