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

Newly bootstrapped Deno project — "Cannot convert object to primitive value" #47

Closed
sjc5 opened this issue Dec 2, 2023 · 0 comments
Closed
Assignees

Comments

@sjc5
Copy link
Owner

sjc5 commented Dec 2, 2023

As incidentally reported by @jaymanmdev in #45, there seems to be a Deno-specific issue around whether it's required to mark parent JSX components as async if they have async children.

If you bootstrap a new Deno project, run npm i && deno task dev, then visit a route, you'll get a "Cannot convert object to primitive value" error.

The fix

Add async in front of the root fn defined in the object arg to renderRoot in your main server entry file.

Example

Broken (before)

return await renderRoot({
  ...,
  root: ({ activePathData }) => <html />
})

Fixed (after)

return await renderRoot({
  ...,
  root: async ({ activePathData }) => <html />
})

Both of the above seem to work in Node, but not in Deno.

Will fix this in the create-hwy templater in next release.

@sjc5 sjc5 self-assigned this Dec 2, 2023
@sjc5 sjc5 mentioned this issue Dec 2, 2023
@sjc5 sjc5 closed this as completed Apr 10, 2024
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.

1 participant