-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
View Transitions reloading JS (not persisting) #8944
Comments
Hi @Brian-McBride, thanks for your minimal example! The effect you are observing is due to a feature introduced in Astro 3.3.3. I'm sorry if this has caused confusion. Do you have any technical issues arising from the new approach that we can help with? |
@Brian-McBride we have now silenced the console to get rid of the irritating messages while we look for client-only stylesheets. |
So, what I have going on is that I have an island that persists. Well, a number of them. Each is a slice of "state" using nanostores and for more complex logic, xstate. What I am seeing is that all these are getting re-init on the client on route change. I have a site with an app in it. The app part, I want to be pretty SPA/PWA style. I think I am hearing that the stylesheet is running the JS on each page transition but completely sandboxed? I ask as the nanostores library drops stuff on the Global object for, well, global access. |
@Brian-McBride What you are experiencing may be effects of the way transition:persist works: the persisted elements will be moved from the old DOM to the new DOM during transitions. They will be unmounted from one DOM and then be mounted into another DOM. The states of the persisted elements should not change. Do your componets use react mounting lifecycle methods? Please try again with Astro 3.4.1. |
Astro Info
If this issue only occurs in one browser, which browser is a problem?
No response
Describe the Bug
I just created a new Astro project. Very simple:
https://github.com/Brian-McBride/astro-persist-failure
In this example, there are a few pages. Each shares a navigation react component.
Visually, things are working ok. However, each time a page loads, it completely re-runs the Javascript from the React component. This seems to be when the client is set to "only." By re-run, this includes all the JS. I am not just talking about the component.
If I set it to
<Nav client:load ... />
it seems to work more as expected. I should only have javascript run once, even on a page transition, if the component is set to persist.What's the expected result?
The JS should only execute once when persisting.
Link to Minimal Reproducible Example
https://github.com/Brian-McBride/astro-persist-failure
Participation
The text was updated successfully, but these errors were encountered: