Skip to content

Latest commit

 

History

History
19 lines (16 loc) · 374 Bytes

File metadata and controls

19 lines (16 loc) · 374 Bytes

Update URL Dynamically (SPA)

const shareButton = useRef(null);

useEffect(() => {
  shareButton.current = new window.SocialShareButton({ 
    container: '#share-button' 
  });
}, []);

useEffect(() => {
  if (shareButton.current) {
    shareButton.current.updateOptions({ 
      url: window.location.href 
    });
  }
}, [pathname]); // Update on route change