justinmahar / react-social-media-embed

📰 Easily embed social media posts from Facebook, Instagram, LinkedIn, Pinterest, TikTok, X (Twitter), and YouTube in React.
https://justinmahar.github.io/react-social-media-embed/
MIT License
215 stars 30 forks source link

InstagramEmbed is loading forever on Next.js@13 #49

Open PiotrSzlagura opened 1 year ago

PiotrSzlagura commented 1 year ago

Hi,

I have a problem with this package - I can't make it work with Next.js version 13. I tried using it with and without SSR, but whatever I do, I see it loading infinitely.

Component which I use to render this embed is as follows:

import { InstagramEmbed } from "react-social-media-embed";

function InstagramEmbedWrapper({ instagramPostUrl }) {
  const [isMounted, setIsMounted] = useState(false);

  useEffect(() => {
    setIsMounted(true);
  }, []);

  if (!isMounted) {
    return null;
  }

  return (
    <div>
      <InstagramEmbed url={instagramPostUrl} debug />
    </div>
  );
}

I added debug prop to try and see what could cause this issue, but all I get in dev console is:

[2023-08-01T10:45:39.924Z]: check-script
[2023-08-01T10:45:39.925Z]: check-script
[2023-08-01T10:45:39.929Z]: load-script
[2023-08-01T10:45:39.942Z]: confirm-script-loaded

No error or warning is thrown.

Is there some trick I could try to make it work?

AnnaRusu commented 1 year ago

Exactly same issue for TwitterEmbed.

vivekneem commented 9 months ago

Any updates on this?

FilipiRafael commented 8 months ago

Hey there @PiotrSzlagura, @AnnaRusu and @vivekneem, did you fix this issue?

sectsect commented 8 months ago

In my case it looks like script loading is not working properly. As a temporary measure, I manually load the script to avoid the issue.

import Script from 'next/script';

{hasInstagramEmbed && (
  <Script
    id={`instagram-embed-${post.id}`}
    src="https://www.instagram.com/embed.js"
  />
)}

As @PiotrSzlagura commented, the console prints the following, but I think it's incorrect information.

[2024-01-06T11:56:33.854Z]: check-script
[2024-01-06T11:56:33.926Z]: check-script
[2024-01-06T11:56:34.205Z]: load-script
[2024-01-06T11:56:34.365Z]: confirm-script-loaded
dominon12 commented 4 months ago

Same issue here with next@12.2.0 and react-social-media-embed@2.5.13. Instagram posts just don't load. Network tab suggests Instagram API returns 404.

Screenshot_11