-
Notifications
You must be signed in to change notification settings - Fork 652
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
Error: Objects are not valid as a React child in Email Demo Preview #1700
Comments
Is this really specific to Windows? It seems to me like something to do with improper dependencies being installed, make sure that you didn't change the lock file. |
I never changed the lock file and tested the And for the Windows, it was a bumpy ride. First, the The readme at the root of this project isn't really clear at telling what the localhost:3000 was supposed to render. e.g. the web & doc or the demo? so i then navigate to "apps/web" and "apps/demo" individually, and run |
Went through the exact steps and didn't get any error, but as I mentioned before, this error is probably because the demo is using X React version and some component is using Y React version. |
appreciate the hint. The different React versions seem to be the cause of the issue. I was able to get "resolutions": {
"react": "18.2.0",
"react-dom": "18.2.0"
} This works as a temporary fix, but it does introduce some issues (e.g., with Next Steps: |
@chuanxshi We can't do it through resolutions for now because the
I've made a PR that should fix these sorts of issues on the future #1706. It should do the same as the |
Same issue occuring using payload beta, since it requires react 19. Silly request, but is there any way to somehow use both versions? |
@DwifteJB This issue is only on internal development, if you are having it while using React Email, you can use whatever React version you want., you aren't fixed in any version, so your issue should be somewhere else other than React Email. react-email/packages/font/package.json Lines 33 to 35 in ad2e6c4
The error for this issue only happens because we use React 19 internally for our apps. |
If I use a new folder, with different node modules will it work fine for rendering with nextjs 19.0.0rc? |
@DwifteJB it will, as long as the React version is the same for the Email React elements creation and the React version being used to render. |
Describe the Bug
Environment
Actual Behavior
An error occurs stating that an object is being incorrectly used as a React child:
Error: Objects are not valid as a React child (found: object with keys {$$typeof, type, key, ref, props}). If you meant to render a collection of children, use an array instead.
The issue seems to occur around the execution of
vm.runInNewContext(builtEmailCode, fakeContext, { filename: emailPath })
.Preliminary Analysis
I have introduced additional logging to trace the output of
fakeContext.module.exports
following the VM execution, which consistently returns{}
, resulting infakeContext.module.exports.default
beingundefined
. This indicates that React components or elements are not being recognized properly but are instead being treated as undefined objects. This issue could be associated with the manner in which the built email code is processed within the Node.js VM context. It suggests potential problems related to serialization or the handling of context isolation by thevm
module, particularly under Windows environments.Suggested Next Steps
vm
module that could affect how execution contexts are handled.Collaboration
I am open to a joint debugging session if other developers have experienced similar issues or have insights into the cause. This might help in identifying and resolving the issue more efficiently.
Which package is affected (leave empty if unsure)
react-email
Link to the code that reproduces this issue
https://github.com/resend/react-email/blob/canary/packages/react-email/src/utils/get-email-component.ts
To Reproduce
Steps to Reproduce
pnpm install
andpnpm run build
at the root.apps/demo
.pnpm run dev
.Expected Behavior
Expected Behavior
The email content should render without errors in the virtual machine context used for SSR.
What's your node version? (if relevant)
20.9.0
The text was updated successfully, but these errors were encountered: