import { useState } from "react"; import { TwitterTweetEmbed } from "react-twitter-embed"; import { useUpdateEffect } from "react-use"; import { useTheme } from "../../hooks/use-theme"; import { styled } from "../../lib/styles/stitches.config"; const Wrapper = styled("div", { // reserve a moderate amount of space for the widget, it takes a while to load... minHeight: "300px", }); export type TweetEmbedProps = { id: string; options?: Record; className?: string; }; const TweetEmbed = ({ id, options, className }: TweetEmbedProps) => { const { activeTheme } = useTheme(); const [widgetTheme, setWidgetTheme] = useState(activeTheme); useUpdateEffect(() => { setWidgetTheme(activeTheme === "dark" ? activeTheme : "light"); }, [activeTheme]); return ( ); }; export default TweetEmbed;