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

@astrojs/lit Hydration Fails #8887

Closed
1 task
andeeplus opened this issue Oct 22, 2023 · 9 comments
Closed
1 task

@astrojs/lit Hydration Fails #8887

andeeplus opened this issue Oct 22, 2023 · 9 comments
Labels
needs triage Issue needs to be triaged

Comments

@andeeplus
Copy link

Astro Info

Astro                    v3.3.0
Node                     v18.18.0
System                   Linux (x64)
Package Manager          npm
Output                   static
Adapter                  none
Integrations             @astrojs/lit

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

Describe the Bug

Hydration do not occur.
Please note that if the component is loaded using the directive client:only="lit" it works correctly.
Looks like an issue with lit/ssr.

I'm worried it could be related with this:
#8825

What's the expected result?

Hydration should work

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-fqvkdx-cut6vb?file=src%2Fpages%2Findex.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 Oct 22, 2023
@lilnasy
Copy link
Contributor

lilnasy commented Oct 24, 2023

It seems to be working fine.
image

Is it possible a lockfile made your package manager install the incompatible version?
Feel free to reopen if there is more to this issue.

@lilnasy lilnasy closed this as completed Oct 24, 2023
@lilnasy lilnasy closed this as not planned Won't fix, can't repro, duplicate, stale Oct 26, 2023
@andeeplus
Copy link
Author

Sorry for the late response.

It works because the client:load one is hydrating the server only. Try to comment the client:only and you will see it's not working. Please reopen.

@lilnasy
Copy link
Contributor

lilnasy commented Oct 28, 2023

I am reopening the issue because you insist (you shouldve been able to do this yourself), but there is nothing to fix here - hydration works the same no matter the client directive. I hope you see how this is just going to create noise for the maintainers and contributors.
9e56f312-bdda-41f8-9544-a1a6f1852a41

@lilnasy lilnasy reopened this Oct 28, 2023
@andeeplus
Copy link
Author

andeeplus commented Oct 28, 2023

image

@lilnasy I'm genuinely disheartened and somewhat disillusioned by your response and the manner in which you've interacted with me. I had hoped to address an issue, but it seems there's been a misunderstanding.

Kindly take note of the distinction: The firs element is intended to be rendered on the server and hydrated on the client while the second is meant for client-side loading. The functionality of the first component is contingent solely on the presence of the second.

image

Now, observe the image below. This isn't functioning as the second element is absent, thus causing the issue.

image

It appears there is an issue with the lit integration, particularly with the lit-labs/ssr module.

@lilnasy
Copy link
Contributor

lilnasy commented Oct 28, 2023

Is it expected that hydration take place in the second case?

@andeeplus
Copy link
Author

Sure, the first component is expected to be hydrated on the client. What would be the reason to render a component that is not hydrated hence not working?

@lilnasy
Copy link
Contributor

lilnasy commented Oct 28, 2023

By default, a UI Framework component is not hydrated in the client. If no client:* directive is provided, its HTML is rendered onto the page without JavaScript.

@andeeplus
Copy link
Author

andeeplus commented Oct 28, 2023

@lilnasy thanks for your answer, I was probably missing the point that the directive was needed. I thought it will be loaded automatically by default once rendered and that the hydration would have been handled directly by lit-lab/ssr. I'm genuinely thankful for your explanation. I hope this ticket can helps somebody doing my same error in the future.

@lilnasy
Copy link
Contributor

lilnasy commented Oct 28, 2023

I hope this ticket can helps somebody doing my same error in the future.

Thanks! That's a good point. I am linking relevant docs for those who find this thread.

https://docs.astro.build/en/core-concepts/framework-components/#hydrating-interactive-components
https://docs.astro.build/en/reference/directives-reference/#client-directives

@lilnasy lilnasy closed this as not planned Won't fix, can't repro, duplicate, stale Oct 28, 2023
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

2 participants