Skip to content
This repository was archived by the owner on Jan 20, 2022. It is now read-only.

Handling embeds with scripts vs. direct iframes #340

Discussion options

You must be logged in to vote

Turns out you need to force a script reload if you are dynamically inserting these embeds. Via Twitter docs:

If content is dynamically inserted into a page (such as lazy-loading content or using a pushState technique to navigate between articles) it’s necessary to parse new buttons and widgets using the twttr.widgets.load() function. TikTok follows a similar pattern, but they haven't exposed a similar method to reload the widgets.

Adding where I landed below in case anyone else runs into this.

// Twitter.tsx

import { useEffect, useState } from "react"
import { Box, Icon } from "components/ui"
import { get } from "utils/fetch"
import { SiTwitter } from "react-icons/si"
import { classNames } 

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by kennethacohen
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants