atellmer / dark

The lightweight and powerful UI rendering engine without dependencies and written in TypeScript💫 (Browser, Node.js, Android, iOS, Windows, Linux, macOS)
MIT License
43 stars 1 forks source link

[data] Make dehydration of DataClient manual #83

Open einar-hjortdal opened 2 months ago

einar-hjortdal commented 2 months ago

I am using a Page component that has an App child component. On the server:

  1. a DataClient is created and given to the App component
  2. The App component is rendered
  3. The DataClient is then given to the Page component. This allows the Page component to use the data needed to render App, without duplicating logic and without performing the same requests twice.
  4. The Page component is rendered and used as response.

This results in 2 <script type="text/dark-state"> elements being generated in the server response to the browser. To prevent this, I propose the DataClient should be dehydrated manually.

einar-hjortdal commented 1 month ago

This problem does still happen. I was wrong closing it.