AVAnnotate / project-client

The source directory for the client code shared by all AVAnnotate projects.
0 stars 0 forks source link

Replace all `client:only` props with `client:load` #80

Closed camdendotlol closed 1 month ago

camdendotlol commented 1 month ago

Summary

This PR replaces all instances of client:only with client:load, addressing #45.

The difference here is that client:only components are fetched by the browser at runtime, through a separate network request for each component contained within what Astro calls an island. This causes a slight delay, especially in deployed environments, as the browser makes dozens of requests for each Astro island.

client:load will include the component in the initial statically generated page, so it's already there on page load. It's then hydrated with whatever props/data are provided at runtime. This is only possible if the component has the props and data it needs to render at the time of page generation, and if the component's first clientside render has the same DOM tree as the server-side render. To accomodate these requirements, this PR adds a couple things:

Whichever PR between #75 and this one is merged second will need to be updated, as that PR adds a few new client:only spots.