diff --git a/src/blocks/tweet/index.tsx b/src/blocks/tweet/index.tsx index dfae468f5..2504bc184 100644 --- a/src/blocks/tweet/index.tsx +++ b/src/blocks/tweet/index.tsx @@ -13,6 +13,7 @@ const wnd = window as any; class TwitterTweet extends React.PureComponent { mounted: boolean = true; + ref = React.createRef(); componentDidMount() { require('scriptjs')('https://platform.twitter.com/widgets.js', 'tw', () => { @@ -22,7 +23,7 @@ class TwitterTweet extends React.PureComponent { console.error('Failed to load Twitter lib.'); return; } - wnd.twttr.widgets.createTweet(this.props.id, this.refs.ref, {theme: this.props.isDark ? 'dark' : 'light'}); + wnd.twttr.widgets.createTweet(this.props.id, this.ref.current, {theme: this.props.isDark ? 'dark' : 'light'}); }); } @@ -31,7 +32,7 @@ class TwitterTweet extends React.PureComponent { } render() { - return this.props.renderWrap(
); + return this.props.renderWrap(
); } } diff --git a/src/routeToBlock.ts b/src/routeToBlock.ts index 4611693fb..ef137b28c 100644 --- a/src/routeToBlock.ts +++ b/src/routeToBlock.ts @@ -66,6 +66,9 @@ const routeToBlock: ReactEmbedRouter = (blocks: Blocks, parsed: ParsedUrl) => { const {hostname, url} = parsed; switch (hostname) { case 'twitter.com': + case 'www.twitter.com': + case 'x.com': + case 'www.x.com': return routeTwitter(blocks, parsed); case 'www.youtube.com': case 'youtu.be': diff --git a/src/stories/ReactEmbed.stories.tsx b/src/stories/ReactEmbed.stories.tsx index a4b31fd1c..edf2ddd0e 100644 --- a/src/stories/ReactEmbed.stories.tsx +++ b/src/stories/ReactEmbed.stories.tsx @@ -33,6 +33,7 @@ const urls = [ 'https://repl.it/@VadimsDaleckis/AwesomeHiddenPublisher', 'https://soundcloud.com/user-515768487/im-a-creeper-boom-boom-boom', 'https://twitter.com/hercuppacoffee/status/911958476678561792', + 'https://x.com/hercuppacoffee/status/911958476678561792', 'https://vimeo.com/54763818', 'https://vimeo.com/12622016', 'https://www.dropbox.com/s/u0bdwmkjmqld9l2/dbx-supporting-distributed-work.gif?dl=0',