react-wrap-balancer
react-wrap-balancer copied to clipboard
Convert Balancer and Provider to server components
Fixes #23
A large part of react-wrap-balancer
can run on the server. I've moved all code that strictly needs to run on the client to client.ts
. This allowed both Balancer
and Provider
to be converted to server components. There are a few significant changes:
-
RelayoutScript
is also rendered on the server and uses a local variable to determine if the relayout function has already been rendered at a global level - React Context was removed entirely and the
Provider
component only renders the relayout script - All code that must run on the client was moved to
ClientBalancer
(effects, relayout) and the rest stayed inBalancer
to be rendered on the server
The latest updates on your projects. Learn more about Vercel for Git ↗︎
Name | Status | Preview | Comments | Updated |
---|---|---|---|---|
react-wrap-balancer | ✅ Ready (Inspect) | Visit Preview | 💬 Add your feedback | Jan 23, 2023 at 0:19AM (UTC) |
Should Balancer
continue to be a client component so it can continue to be used in other client components (see this doc)? I chose to make it a server component so we could remove React Context and render the relayout script and provider on the server, but there might be a better way of doing this.
Any progress on this? Will be really helpful
Cannot set a CSP nonce
the server script, that should probably be added.