KyleJune / deno-tailwind-ui-react-example

An example of how you can use Tailwind UI and React with Deno
20 stars 5 forks source link

Add react suspense example #5

Closed KyleJune closed 2 years ago

KyleJune commented 2 years ago

https://github.com/reactwg/react-18/discussions/37

For this, I'd like to add a utils.ts file with functions for checking if using server or browser rendering to determine whether or not a component is rendered on the server or on the client only.

KyleJune commented 2 years ago

It looks like react 18 will be released in 1-3 weeks. I'm not sure if renderToPipeableStream will work with Deno, investigate that before switching to using it instead of renderToString. If it doesn't, renderToString will use the fallback. Until react 18 is released, I will need to use my isServer() function and conditionally use the fallback or suspense element depending on if rendering on the server.