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

Use mutationObserver to monitor for new components on the screen #136

Open
ersinakinci opened this issue Apr 9, 2024 · 0 comments
Open
Labels
enhancement New feature or request

Comments

@ersinakinci
Copy link

What is the feature you are proposing?

I'm using htmx in my project, which fetches new pages via XHR when you click on a link to allow for smooth, client-side routing during navigation.

Unlike other client-side frameworks, the XHR request fetches raw HTML. htmx swaps out the current DOM tree for the one returned by the server response.

This means that my client script that uses createClient doesn't execute for the new Hono JSX components that were rendered by SSR as part of the server response. In other words, my components are interactive when I do a hard refresh, bypassing htmx, but they're non-interactive if they're loaded using htmx's XHR mechanism.

I think we could use MutationObserver to hydrate if a new Hono component appears on the screen and it hasn't been hydrated yet. We already use this approach to monitor for components streamed by suspense.

@ersinakinci ersinakinci added the enhancement New feature or request label Apr 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant