GithubHelp home page GithubHelp logo

vercel / react-tweet Goto Github PK

View Code? Open in Web Editor NEW
1.2K 9.0 59.0 783 KB

Embed tweets in your React application.

Home Page: https://react-tweet.vercel.app

License: MIT License

TypeScript 56.03% CSS 14.81% JavaScript 5.81% HTML 1.24% MDX 22.12%

react-tweet's Introduction

react-tweet

react-tweet allows you to embed tweets in your React application when using Next.js, Create React App, Vite, and more.

For documentation visit react-tweet.vercel.app.

Contributing

Visit our contributing docs.

react-tweet's People

Contributors

brianlovin avatar ctjlewis avatar garutyunov avatar github-actions[bot] avatar ianmuchina avatar illyism avatar ilyichv avatar jahirfiquitiva avatar jaredpalmer avatar joulev avatar leerob avatar lfades avatar maxleiter avatar milhamm avatar rafaelgiro avatar stefkors avatar tywayne avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

react-tweet's Issues

Global css

Installed this package with npm install next-tweet and got error in my project when compiling:
error - ./node_modules/next-tweet/dist/theme.css
Global CSS cannot be imported from within node_modules.
Thought I could just use my server to get tweet data and use EmbeddedTweet to display it.

CSS being loaded when `react-tweet` isn't on the page

I was recently looking at some page speed insights for my website and noticed that I was getting Avoid chaining critical requests https://pagespeed.web.dev/analysis/https-www-redshirtsports-xyz-chicago-states-case-for-the-nec/rz9c7fcabb?form_factor=mobile which is basically adding almost 3 seconds to my load time

Screenshot 2023-11-29 at 1 49 39 PM

The first one is for tailwindcss but I noticed the second and 3rd are for react-tweet.

If you go to the URL being tested, you can see there is no tweet being rendered, so not sure why that CSS is being added.

I use react-tweet in my custom portable text component for Sanity. Could it be that just because it's a possibility that it gets added that Next is adding this CSS?

import Image from 'next/image'
import {
  PortableText,
  PortableTextComponents,
  PortableTextMarkComponentProps,
} from '@portabletext/react'
import { PortableTextBlock } from 'sanity'
import { Tweet } from 'react-tweet'

import type { TwitterComponents } from 'react-tweet'


const TweetComponents: TwitterComponents = {
  AvatarImg: (props) => <Image {...props} alt={props.alt} />,
  MediaImg: (props) => <Image {...props} alt={props.alt} fill unoptimized />,
}

export function CustomPortableText({
  paragraphClasses,
  value,
}: {
  paragraphClasses?: string
  value: PortableTextBlock[]
}) {
  const components: PortableTextComponents = {
    types: {
      twitter: ({ value }) => {
        return (
          <div className="not-prose flex items-center justify-center">
            <Tweet id={value.id} components={TweetComponents} />
          </div>
        )
      },
    },
  }

  return <PortableText components={components} value={value} />
}

Module parse failed: Cannot use 'import.meta' outside a module

image
- error ./node_modules/react-tweet/node_modules/@babel/runtime/helpers/interopRequireDefault.js
Module parse failed: Cannot use 'import.meta' outside a module (39:16)
|                 // still a Refresh Boundary later.
|                 // @ts-ignore importMeta is replaced in the loader
>                 import.meta.webpackHot.accept();
|                 // This field is set when the previous version of this module was a
|                 // Refresh Boundary, letting us know we need to check for invalidation or


Getting the following error while running.

package.json:

    "eslint-config-next": "^13.4.2",
    "next": "^13.4.2",
    "next-auth": "^4.22.1",
    "react": "^18.2.0",
    "react-dom": "^18.2.0",
    "react-tweet": "^2.0.1",

Component is unstyled in light mode when there is no `data-theme`

The theme.css file includes several CSS variables that are only active when either a data-theme attribute is present or the user's prefers-color-scheme is set to dark. In the absence of a data-theme attribute, the component will appear unstyled in light mode (e.g. lack of borders and colors) but properly styled in dark mode. It would be better to provide styling for the light mode as well, instead of leaving the component unstyled.

light mode

dark mode

SEO (Google Search Console) -> Video page indexing > Video outside the viewport

Edge Case Problem:

It's awesome that some tweets embed videos and load video markup, but sometimes when the tweet is below the fold line this video element is not lazy loaded. This is especially important when the video is considered supplementary content and not the main content from SEO perspective.

SEO  (Google Search Console) -> Video page indexing > Video outside the viewport

Proposed Solution:

It would be useful to provide a prop for lazy loading video elements when they become visible in the viewport. In some cases, however, it would actually harm SEO (for example, when the video is the main content or above the fold line!).

Video would be loaded as it does now by default, but the additional props, say videoLazyLoad, would allow this video to be lazy loaded. Content such as reviews or other sections of the page not included in the main content would benefit from this feature.

More details of the issue:

Two types of videos placement from SEO perspective:

Video placement types Google Search Console

This is the Google Search Console issue detected example:

CleanShot 2023-09-30 at 12 53 29@2x

Link to the page with example issue:

https://www.listedai.co/ai/qrgpt-ai-art-qr-code-generator

Visual explanation of the issue:

CleanShot 2023-09-30 at 12 55 25@2x

TypeError: Cannot read properties of undefined (reading 'screen_name')

Hello I'm getting this error:

- error node_modules\react-tweet\dist\utils.js (1:63) @ screen_name
- error TypeError: Cannot read properties of undefined (reading 'screen_name')
    at stringify (<anonymous>)

and use it like this:

import { Tweet } from 'react-tweet';

const MOCKED_TWEETS = ['mock_tweet#1', 'mock_tweet#2', 'mock_tweet#3'];

export default function TwitterFeed() {
  return (
    <div className="flex flex-col w-1/5">
      {MOCKED_TWEETS.map((tweetId) => (
        <Tweet key={tweetId} id={tweetId} />
      ))}
    </div>
  );
}

any ideas?

Does not play nicely with Next.js App Directory

This library started giving the following error when used in the app directory

DynamicServerError: Dynamic server usage: no-store fetch https://cdn.syndication.twimg.com/tweet-result?id=1631369196163440648&lang=en&features=tfw_timeline_list%3A%3Btfw_follower_count_sunset%3Atrue%3Btfw_tweet_edit_backend%3Aon%3Btfw_refsrc_session%3Aon%3Btfw_show_business_verified_badge%3Aon%3Btfw_duplicate_scribes_to_settings%3Aon%3Btfw_show_blue_verified_badge%3Aon%3Btfw_legacy_timeline_sunset%3Atrue%3Btfw_show_gov_verified_badge%3Aon%3Btfw_show_business_affiliate_badge%3Aon%3Btfw_tweet_edit_frontend%3Aon /[slug]
    at /Users/jamessingleton/Code/Projects/redshirt-sports/node_modules/next/dist/server/lib/patch-fetch.js:261:37
    at /Users/jamessingleton/Code/Projects/redshirt-sports/node_modules/next/dist/server/lib/trace/tracer.js:108:36
    at NoopContextManager.with (/Users/jamessingleton/Code/Projects/redshirt-sports/node_modules/next/dist/compiled/@opentelemetry/api/index.js:1:7057)
    at ContextAPI.with (/Users/jamessingleton/Code/Projects/redshirt-sports/node_modules/next/dist/compiled/@opentelemetry/api/index.js:1:516)
    at NoopTracer.startActiveSpan (/Users/jamessingleton/Code/Projects/redshirt-sports/node_modules/next/dist/compiled/@opentelemetry/api/index.js:1:18086)
    at ProxyTracer.startActiveSpan (/Users/jamessingleton/Code/Projects/redshirt-sports/node_modules/next/dist/compiled/@opentelemetry/api/index.js:1:18847)
    at /Users/jamessingleton/Code/Projects/redshirt-sports/node_modules/next/dist/server/lib/trace/tracer.js:97:107
    at NoopContextManager.with (/Users/jamessingleton/Code/Projects/redshirt-sports/node_modules/next/dist/compiled/@opentelemetry/api/index.js:1:7057)
    at ContextAPI.with (/Users/jamessingleton/Code/Projects/redshirt-sports/node_modules/next/dist/compiled/@opentelemetry/api/index.js:1:516)
    at NextTracerImpl.trace (/Users/jamessingleton/Code/Projects/redshirt-sports/node_modules/next/dist/server/lib/trace/tracer.js:97:32)
    at globalThis.fetch (/Users/jamessingleton/Code/Projects/redshirt-sports/node_modules/next/dist/server/lib/patch-fetch.js:31:47)
    at getTweet (webpack-internal:///(sc_server)/./node_modules/react-tweet/dist/api/get-tweet.js:38:23)
    at TweetContent (webpack-internal:///(sc_server)/./node_modules/react-tweet/dist/tweet.js:19:85)
    at attemptResolveElement (webpack-internal:///(sc_server)/./node_modules/next/dist/compiled/react-server-dom-webpack/cjs/react-server-dom-webpack-server.edge.development.js:1091:30)
    at resolveModelToJSON (webpack-internal:///(sc_server)/./node_modules/next/dist/compiled/react-server-dom-webpack/cjs/react-server-dom-webpack-server.edge.development.js:1366:41)
    at Object.toJSON (webpack-internal:///(sc_server)/./node_modules/next/dist/compiled/react-server-dom-webpack/cjs/react-server-dom-webpack-server.edge.development.js:948:28)
    at stringify (<anonymous>)
    at processModelChunk (webpack-internal:///(sc_server)/./node_modules/next/dist/compiled/react-server-dom-webpack/cjs/react-server-dom-webpack-server.edge.development.js:156:24)
    at retryTask (webpack-internal:///(sc_server)/./node_modules/next/dist/compiled/react-server-dom-webpack/cjs/react-server-dom-webpack-server.edge.development.js:1605:38)
    at performWork (webpack-internal:///(sc_server)/./node_modules/next/dist/compiled/react-server-dom-webpack/cjs/react-server-dom-webpack-server.edge.development.js:1643:21)
    at Timeout.eval [as _onTimeout] (webpack-internal:///(sc_server)/./node_modules/next/dist/compiled/react-server-dom-webpack/cjs/react-server-dom-webpack-server.edge.development.js:1188:28)
    at listOnTimeout (node:internal/timers:559:17)
    at processTimers (node:internal/timers:502:7) {
  digest: 'DYNAMIC_SERVER_USAGE'
}

This is how I am using it in my application

import Image from 'next/image'
import {
  PortableText,
  PortableTextComponents,
} from '@portabletext/react'
import { PortableTextBlock } from 'sanity'
import { Tweet } from 'react-tweet'

const TweetComponents: TweetComponents = {
  AvatarImg: (props) => <Image {...props} alt={props.alt} />,
  MediaImg: (props) => <Image {...props} alt={props.alt} fill unoptimized />,
}

export function CustomPortableText({
  value,
}: {
  value: PortableTextBlock[]
}) {
  const components: PortableTextComponents = {
    types: {
      twitter: ({ value }) => {
        return (
          <div className="not-prose flex items-center justify-center">
            <Tweet id={value.id} components={TweetComponents} />
          </div>
        )
      },
    },
  }

  return <PortableText components={components} value={value} />
}

Feature Proposal: Extend functionality to include User profile embedding

The theming capabilities of this package are quite robust, and I believe it can accommodate more than just individual tweets. I propose adding the ability to embed user profiles, in addition to single tweets.

Currently, the package allows for the embedding of individual tweets using getTweet to fetch tweet data from the api then EmbeddedTweet component for rendering it.

Support for embedding user profiles can be achieved by incorporating the ${SYNDICATION_URL}/srv/timeline-profile/screen-name/${screenName} endpoint, which would provide the necessary data to render user profiles and their tweets. Should be a getProfile or getTimeline function that serves a similar purpose for getTweet. It can perform any response format changes to match Tweet type.

weired tweet.user is undefined

With this tweet id = '1716120243775402095' => "This Post is from an account that no longer exists"
I get this error: 'TypeError: tweet.user is undefined'

my code:

const { data, error, isLoading } = useSWR('/api/tweets/' + tweetId, fetcher);

    if (isLoading) {
        return (<TweetSkeleton />)
    }
    else if (error) {
        return null// (<TweetNotFound />)
    } else {
        //console.log(data.data);
        if (data.data) {
            const tweet = enrichTweet(data.data);  <== Problem here 

how can i check this before hand?

import error: 'swr' does not contain a default export (imported as 'swr').

We are encountering a error related to the swr library with the react-tweet module in a Next.js application. The error manifests as a TypeError, specifically when trying to access the default export of the swr module within react-tweet. This issue is presenting challenges in both server-side and client-side contexts, affecting the normal operation of our Next.js application.

Error Details
The error we're encountering is as follows:
server side:

./node_modules/react-tweet/dist/hooks.js
Attempted import error: 'swr' does not contain a default export (imported as 'swr').

Import trace for requested module:
./node_modules/react-tweet/dist/hooks.js
./node_modules/react-tweet/dist/index.client.js

client:

error - node_modules/react-tweet/dist/hooks.js (6:15) @ swr
TypeError: Cannot read properties of undefined (reading 'default')

The line of code causing the issue in react-tweet/dist/hooks.js is:

const useSWR = swr.default || swr;

This line suggests an attempt to handle both default and named exports of swr, but it fails because swr is undefined at this point.

Steps Taken to Resolve
Verified Import Syntax: Checked that swr is being imported correctly in react-tweet. The issue seems not to be with the import syntax but rather with the swr module resolution.

Checked Module Resolution: Explored potential module resolution issues, ensuring that swr is correctly installed and that there are no path discrepancies or version conflicts.

Reviewed Next.js Transpilation and Bundling: Investigated whether the Next.js build and transpilation process might be affecting how swr is bundled or executed, particularly in the context of server-side rendering (SSR).

Node Modules Reinstallation: Attempted deleting and reinstalling node_modules to rule out any corrupt or improperly installed packages.

Checked for Version Compatibility: Ensured that the versions of swr, react-tweet, and Next.js in use are compatible with each other.

Request for Assistance
Any guidance, especially from those who might have faced similar challenges, would be greatly appreciated. We are particularly interested in understanding why the swr module is resolving as undefined in this context and how we might address this in a Next.js environment.

Adding several tweets (tens) in a single page

Are there a way to create static tweets in a single page by making a reference to the tweets ID. I need to do that so that I can close my twitter account while keeping my library of tweets and bookmarks. Thanks a lot.

Tweet title overflow when resizing

Max width of tweets is 550px but they can go down to 250px. I tried to resize them to 400px width and the tweet icon in top right corner is going over title.
You can check this on this tweet id 1636101793745711105.

Error following NextJS-example

Trying to implement the NextJS-example into an existing project (using pages-Router), I am stuck with this error:
TypeError: Cannot read properties of undefined (reading 'in_reply_to_status_id_str')

Is it possible, that Twitter has changed its API?

release

can someone please release the latest features?

Tweet Not Found

I know there is already another issue for this #134 but they closed it without an actual resolution from the library itself. I can get the tweet to load on localhost:3000 just fine
Screenshot 2023-09-04 at 12 03 45 PM

However, when I am previewing it through a deployment branch, it just returns Tweet not found

Screenshot 2023-09-04 at 12 02 55 PM

I get no errors in my Vercel logs at all and nothing in the console and nothing in the network tab. This is currently stopping me from publishing some changes to my website.

So I decided to just push my changes to production and just tell my authors to not include tweets for the time being... However, I can now see errors in Vercel but all it is saying is

Error: Failed to get tweet data for tweet ID: 1556693648762437637
    at getTweets (/var/task/.next/server/pages/[slug].js:676:15)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async getStaticProps$1 (/var/task/.next/server/pages/[slug].js:156:31)
    at async /var/task/node_modules/@sentry/nextjs/cjs/server/utils/wrapperUtils.js:38:14 {
  page: '/vmi-gets-a-commitment-from-2023-3-star-cb-davion-corpening'
}
RequestId: 0581bce3-020b-4225-902f-5ad7b122e9b2 Error: Runtime exited with error: exit status 1
Runtime.ExitError

However, the tweet does exist https://twitter.com/IamTheKeyDC/status/1556693648762437637

[Help] remove/hide items from the tweet

Hi, i need to remove/hide the TweetInfo and TweetReplies from the tweet.
i can simply 'remove' them from embedded-tweet.js but i need to do keep updating the library.
is there a way to do this?

Mute/Pause video tweet?

I have a list of tweets, and i need a way Mute/Pause the video tweet on scroll.
is there any API Reference to call?
Thank you

HTML entities not decoded in output

Tweet bodies that contain encoded HTML entities are not being decoded in the rendered output.

Example API response:
https://cdn.syndication.twimg.com/tweet-result?id=1631503729143738375

Link to that tweet in the example app:
http://localhost:3000/dark/1631503729143738375

Screenshot of the output, the code snippet is rendering &gt; instead of >:

Screenshot 2023-03-04 at 10 09 35 PM

Potential Solution

Depending on whether you assume the response from the API is trusted/santized, this could be as easy as using dangerouslySetInnerHtml on the <span> in TweetBody, something like this:

return <span key={i} dangerouslySetInnerHTML={{__html: text }} />

instead of the current line
https://github.com/vercel-labs/next-tweet/blob/e48dceae3fe8bbffd4c877fa8d8b56da2d12f9ce/packages/next-tweet/src/tweet-body.tsx#L105

Happy to put up a quick PR with this change, just didn't know for sure if you'd want/need to do any additional sanitation before setting it dangerously.

Tweet not found

Tweet not found, even though It exist. No tweets are being rendered.
image

Remix, missing css modules

I'm trying to use this library in my react remix project, and having trouble importing the css.

I updated the remix config to include react-tweet

/** @type {import('@remix-run/dev').AppConfig} */
export default {
  ignoredRouteFiles: ["**/.*"],
  serverDependenciesToBundle: [
    /react-tweet/,
  ],
};

And Remix CSS bundling is enabled.. but the CSS seems to be missing from the <Tweet/> component.

<Tweet id="1448382615904346113" />

output:
image

Question: React Native?

is there any way to use this library in a react native app?.. at least the API?
I need to load a (large) list of tweets.. performance in react native will be an issue .

Previously working tweets now crashing on getTweetUrl call

react-tweet version 3.1.0, 3.0.4 as well.
nextjs 13.4.7

These 3 tweets

export const TWEETS = ["1689246608557547520", "1688132424012627968", "1689018484343083008"];

https://twitter.com/aryarsh11/status/1689018484343083008
https://twitter.com/its_justmedude/status/1689246608557547520
https://twitter.com/_AlexAstro/status/1688132424012627968

were working for the last 2 weeks on my site and now my site is crashing with the following error

- error node_modules/react-tweet/dist/utils.js (1:63) @ screen_name
- error TypeError: Cannot read properties of undefined (reading 'screen_name')
    at stringify (<anonymous>)
null
digest: "4154291835"

-  ┌ GET / 200 in 1745ms
   │
   ├──── GET https://cdn.syndication.../tweet-result?id=168924660855.. 200 in 102ms (cache: MISS)
   │
   ├──── GET https://cdn.syndication.../tweet-result?id=168813242401.. 200 in 108ms (cache: MISS)
   │
   └──── GET https://cdn.syndication.../tweet-result?id=168901848434.. 200 in 109ms (cache: MISS)

I suspected it was the first tweet because of the deleted retweet, but when I try on any tweet from my timeline it does not seem to work.

Here is the code that references it (which has been unchanged for 2 weeks now).

import { CURRENT_USER_COUNT, TWEETS } from "@/constants";
import { Tweet } from "react-tweet";

export default async function Feedback() {
  return (
    <div className="my-8 md:my-16 lg:my-24 max-w-7xl mx-auto">
      <div className="max-w-3xl mx-auto">
        <h2 className="text-3xl/snug sm:text-4xl/snug font-bold tracking-tight mb-4">
          What are people saying about Scale Sleek?
        </h2>
        <p className="mb-6">
          Since our launch, we&apos;ve had over {CURRENT_USER_COUNT} users sign up for our service. Here&apos;s what
          some of them have to say about our service. We hope to add your testimonial soon!
        </p>
      </div>
      <div className="text-left mx-auto grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">
        {TWEETS.map((tweetId) => (
          <Tweet key={tweetId} id={tweetId} />
        ))}
      </div>
    </div>
  );
}

I've tried it as a client component as well as a prelim debug step and it did not work either.

"use client"

import { CURRENT_USER_COUNT, TWEETS } from "@/constants";
import { Tweet } from "react-tweet";

export default function Feedback() {
  return (
    <div className="my-8 md:my-16 lg:my-24 max-w-7xl mx-auto">
      <div className="max-w-3xl mx-auto">
        <h2 className="text-3xl/snug sm:text-4xl/snug font-bold tracking-tight mb-4">
          What are people saying about Scale Sleek?
        </h2>
        <p className="mb-6">
          Since our launch, we&apos;ve had over {CURRENT_USER_COUNT} users sign up for our service. Here&apos;s what
          some of them have to say about our service. We hope to add your testimonial soon!
        </p>
      </div>
      <div className="text-left mx-auto grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">
        {TWEETS.map((tweetId) => (
          <Tweet key={tweetId} id={tweetId} />
        ))}
      </div>
    </div>
  );
}

Gatsby Partial Hydration

In the process of trying out if next-tweet (soon to be renamed to react-tweet) could work with Gatsby's Partial Hydration (the feature that implements React Server Components), multiple issues were found and the on progress app was removed in #44

Here are the issues I've found so far:

CSS Modules

CSS Modules in Next.js, Vite, CRA, Remix and similars import the default export:

import styles from './app.module.css'

In Gatsby the above does not work unless it's changed to:

import * as styles from './app.module.css'

Changing the imports to support Gatsby can break other libraries so instead I went with this change to its webpack config: apps/gatsby-app/gatsby-node.js

Global CSS

react-tweet has an import for a global CSS file that implements all the CSS variables that the tweet uses. This worked well elsewhere but in Gatsby those styles were not being included, so the following had to be done in order to use the tweet components:

import s from 'next-tweet/theme.css'
console.log(s) // This line can't be removed

It's a workaround for this issue: gatsbyjs/gatsby#19446

React Server Components (RSC)

After the CSS issues are handled with the workarounds, react-tweet has can be used client-side in Gatsby, just like in Vite and CRA. However, after enabling Gatsby's Partial Hydration with the following flag:

flags: {
  PARTIAL_HYDRATION: true,
},

All I could see was a blank screen and the following error in the browser console:

image

The react version was set to experimental and pnpm was used with the gatsby-plugin-pnpm plugin installed.

Design of the `TweetComponents` type

The TweetComponents type is used for the components prop on both Tweet and EmbeddedTweet. It has an optional slot for providing a TweetNotFound component, but TweetNotFound is only ever used by Tweet, not EmbeddedTweet.

IMO it is confusing to allow a prop to be passed to a component that is never utilized. I can see a consumer passing something to that slot, expecting it to do something. I think a better design would be to maintain separate types for the components prop of Tweet and EmbeddedTweet.

Doesn't handle some emojis well

If you look at the console going to https://static-tweet.vercel.app/1556693648762437637 there are a couple errors that occur all coming from the 🤙 emoji. Running locally you get Prop dangerouslySetInnerHTML did not match. Server: " Ready to be a part of the Keydets brotherhood🤙" Client: " Ready to be a part of the Keydets brotherhood🤙\ud83c" along with Uncaught Error: Text content does not match server-rendered HTML. and Uncaught Error: There was an error while hydrating this Suspense boundary. Switched to client rendering..

Another issue is that if you go to the Static tweet example I gave above, the entire hashtag #Redswarm isn't a link, all up until the rm is a link leaving those letters out.

Control where styles are injected

Hi, thanks for making this. I need to render tweets within a controlled iframe, and manually inject the CSS for any elements in it, however the library is injecting the CSS Modules styles on the main document, is there any workaround for this?

Throw a better error if `<NextTweet>` is used inside a client component

Currently NextTweet is a RSC so cannot be used in the pages directory or in a client component (from now we call these "client components" for short).

But if we do use it like that, the error is very unclear, something like

Objects are not valid as a React child (found: [object Promise]). If you meant to render a collection of children, use an array instead.

So I think the package should throw a clearer error.

I have thought of three ways to do it.

  1. Check for window → this doesn't really work because the error can only be thrown in runtime, not in prerender where window is still undefined.

  2. Use server-only → the error message is not much better.

    This module cannot be imported from a Client Component module. It should only be used from a Server Component.

  3. Make a custom server-only and customise the error message.

The third way works, but it would effectively makes the whole package available only on server-side, so components like <TweetSkeleton> can no longer work in client components. I even tried to dynamically import server-only, but that doesn't suffice.

All three have drawbacks and don't work one way or another, and I don't know of a fourth way. So while I planned to make a PR, I decided to open this issue instead. What do you think about this?

Global CSS cannot be imported from within node_modules.

I'm getting this error after creating a simple app with yarn create next-app

and placing this code -

`import { Tweet } from "react-tweet";

export default function Test() {
return ;
}
`

in a new page under the pages folder.

image

New Twitter Logo

Hey folks, the Twitter logo changed from the Bird to an X.
Could you please change it?

Customize onError behavior

Right now, notFoundOnError either throws an error or displays the predefined "Not Found" text. It might be more flexible to provide an onError callback to render a custom message or hide it completely. Or is the intention to wrap the error in an ErrorBoundary?

Error while importing react-tweet

Issue

Getting an error while importing react-tweet package.

CSS Modules cannot be imported from within node_modules

image

Versions

"react-tweet": "^3.0.4"
"react": "18.2.0"
"next": "13.0.0"

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.