Open theslantedroom opened 9 months ago
I have the same issue with ViewTransitions in Astro v4.5 and react-select v5.8. Tried every other workaround I could find to make it hydrate properly, but was still having problems with back navigation.
For anyone who encounters this in the future, I fixed it using the data-astro-reload
attribute on links to pages containing the Select components in combination with this crude script in my Astro layout to detect and reload those pages
---
const path = Astro.url.pathname
---
<script is:inline define:vars={{path}}>
const listOfPaths = [...];
document.addEventListener("astro:after-swap",()=>{
if (listOfPaths.includes(path)){
history.go(0);
}
})
</script>
Having written that out, I now realise that the script has made the data-astro-reload
attribute redundant 🤦♂️
In astro3 with ViewTransitions enabled, and the React integrations, this components css is lost every time a viewTransition fires. So whenever you navigate.
https://docs.astro.build/en/guides/view-transitions/
https://docs.astro.build/en/guides/integrations-guide/react/
https://github.com/JedWatson/react-select/assets/73557008/c9b138b2-48ca-4246-bd97-d7c09f75f055