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

Use react context for twind #11

Closed KyleJune closed 2 years ago

KyleJune commented 2 years ago

Currently twind is using global state which requires rendering to be synchronous. twind has a create function for creating a twind context and I could share the tw function through a react context. Create a style provider for storing the required information. At the end replace the style tag in the same way I currently am, just with the request's twind instance instead of the global instance.

https://reactjs.org/docs/context.html https://twind.dev/api/modules/twind.html#create