Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Satori does not work with components which are using forwardRef #600

Open
sdorra opened this issue Mar 7, 2024 · 3 comments · May be fixed by #601
Open

Satori does not work with components which are using forwardRef #600

sdorra opened this issue Mar 7, 2024 · 3 comments · May be fixed by #601

Comments

@sdorra
Copy link

sdorra commented Mar 7, 2024

Bug report

Description / Observed Behavior

Satori does not render components which are using forwardedRef. For example FontAwesomeIcon.

Expected Behavior

Satori should render components which are using React.forwardRef.

Reproduction

The following demo uses the latest next.js canary and should show 👋 Hello World 👋, instead it renders only World 👋 the 👋 Hello uses a forwardRed and is not rendered.

https://github.com/sdorra/og-with-forwardRef

@sdorra
Copy link
Author

sdorra commented Mar 7, 2024

I've already opened an issue at next.js, but i think it is more a satori bug than a next.js one.

shuding added a commit that referenced this issue Mar 11, 2024
@shuding shuding linked a pull request Mar 11, 2024 that will close this issue
@Yovach
Copy link

Yovach commented Dec 11, 2024

This issue also applies to this one #570

@kachkaev
Copy link

kachkaev commented Jan 24, 2025

👋 @shuding! Could you please consider merging #601 to fix this issue? I am trying to use qrcode.react via next/og (i.e. @vercel/satori) but failed. The <svg> element does not render because of forwardRef in qrcode.react.

I guess that forwardRef will be eventually deprecated but it’s probably too early to ask maintainers to remove it for satori to work.


Another issue with satori that I noticed was incompatibility with useMemo:

Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:
1. You might have mismatching versions of React and the renderer (such as React DOM)
2. You might be breaking the Rules of Hooks
3. You might have more than one copy of React in the same app
See https://react.dev/link/invalid-hook-call for tips about how to debug and fix this problem.
 ⨯ [Error: failed to pipe response] {
  [cause]: [TypeError: Cannot read properties of null (reading 'useMemo')]
}

I could overcome this locally by temporarily replacing React.useMemo(fn, deps) with (x => x())(fn, deps) . When I also removed forwardRef from node_modulesqrcode.reactesm/index.js, QR-codes finally rendered in satori.

The useMemo issue might be to do with React version mismatch between Next.js (resolved as built-in canary) and qrcode.reactpeerDependencies (resolved as v19.0.0).


Both useMemo and forwardRef are compatible with server components, so it’d be great to see them working in satori too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants