sjc5 / hwy

Hwy is a fullstack web framework for driving a (p)react frontend with a Go backend. Includes end-to-end typesafety, file-based nested UI routing, and much more.
BSD 3-Clause "New" or "Revised" License
317 stars 3 forks source link

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

Closed sjc5 closed 5 months ago

sjc5 commented 10 months ago

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.