Skip to content
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

Styled Component is not applied when navigating with View Transition #11000

Closed
1 task
nojaf opened this issue May 10, 2024 · 3 comments
Closed
1 task

Styled Component is not applied when navigating with View Transition #11000

nojaf opened this issue May 10, 2024 · 3 comments
Labels
needs triage Issue needs to be triaged

Comments

@nojaf
Copy link

nojaf commented May 10, 2024

Astro Info

Astro                    v4.8.2
Node                     v18.18.0
System                   Linux (x64)
Package Manager          npm
Output                   static
Adapter                  none
Integrations             @astrojs/react

If this issue only occurs in one browser, which browser is a problem?

Chrome

Describe the Bug

A styled component (via React client:only) will only render correctly if it is on the initial page load.
When navigating via a View Transition the style will not be applied.

What's the expected result?

The style is always applied after each page transition.

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-wut9d2?file=src%2Fpages%2Fanother.astro

Participation

  • I am willing to submit a pull request for this issue.
@github-actions github-actions bot added the needs triage Issue needs to be triaged label May 10, 2024
@martrapp
Copy link
Member

martrapp commented May 11, 2024

Hi @nojaf, it looks like @emotion/styled is not working with <ViewTransitions />.

You need to find a way to update the lib's internal state after view transitions. I skimmed through @emotion/* but didn't find an obvious way how to do that.

For more information see https://docs.astro.build/en/guides/view-transitions/#script-behavior-with-view-transitions

@nojaf
Copy link
Author

nojaf commented May 13, 2024

Thanks a bunch for this solution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs triage Issue needs to be triaged
Projects
None yet
Development

No branches or pull requests

3 participants