-
Notifications
You must be signed in to change notification settings - Fork 43
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
<honox-island> tag breaks direct child CSS #141
Comments
Sorry for the delayed reply.
Yeah, this causes some problems, including the CSS issue. We'll try to fix it. |
Astro has the same issue. One user wrote a blog post about how to apply CSS to islands in the Astro application: https://zellwk.com/blog/overcoming-astro-styling-frustrations/ Astro and Hono are using the same strategy for islands that apply additional tags like However, if using the "comment" strategy is difficult or impossible, we have to keep using |
Hi @usualoma I need your help! What do you think about this issue? I've been struggling to resolve it for a long time, but I can't. This means using |
This is a difficult issue. I understand that the current To avoid the impact on evaluating CSS, I think a comment node would be appropriate, as you say, but we can't directly put it out in React. If we were to do this, we could use the script element If you ask whether it's possible or impossible, I think it's possible, but it's not so clean. If this is only "to solve the CSS problem", then I feel that the current #155 (which doesn't happen with hono/jsx/dom, but with React's hydrateRoot, I think) is worth considering if this solves the problem. (I haven't checked to see if this solves it) Well, Maaaybe, Although this is not clean, I think the performance is not so bad if we implement it with a bit of ingenuity. I think I'll give it a try. |
Ah, using React, would we be able to insert a component later in the middle of a DOM node such as <div>
Before.
<ClientComponent />
After
</div> Current honox is fine as Do you know if such hydration is possible in React? |
@usualoma Thank you for your response!
I'm also thinking so. Since, as you said, using the comment strategy is "not clean," it will be better to use
Hmm. Indeed, I think it is impossible... By the way, Fresh is following the comment strategy: https://fresh.deno.dev/docs/concepts/islands#passing-other-props-to-islands <!--frsh-myisland_default:default:0-->
<div>
Counter is at 0.
<button>+</button>
<!--frsh-slot-myisland_default:children-->
<p>This text is rendered on the server</p>
<!--/frsh-slot-myisland_default:children-->
</div>
<!--/frsh-myisland_default:default:0--> But in the Fresh case, it uses only Preact, so it can add comments in the rendering phase. What we want to do is support any JSX UI library, at least hono/JSX, and React, so we have to do it in the Vite/JSX translation phase. Both are different. Then, my current answer is to keep using |
I have an idea to solve #155 but I think we need to use Set up as follows, export default defineConfig({
plugins: [honox({
useContextModule: 'react',.
// this setting is used in server side
// default is 'hono/jsx'
})],
}) The following line is automatically inserted. import { useContext } from 'react' I don't want to add the server configuration item if possible, but I don't think there is any other way. Do you think this is the way to do it? |
Hmm. I also don't want to do it. One of my interesting ideas. How about using this method, which it can mark if it is a client component or not by adding app.get('/', (c) => {
return c.render(
<>
<Counter $client initial={3} />
</>
)
}) I've tried a super rough implementation as PoC: https://github.com/yusukebe/hydrate-dollar-client This demo can avoid a hydration error, and it is rendered as we expected. One of the good things is we can use named exported components, not just exported as a |
I think it's an awesome idea! And you're right, the "Nemed exported component" problem is solved too!
I think the implementation is also largely fine, but I think the biggest issue is here. However, I think we need to think about solving the "nested islands" problem separately. I don't think the "hydrate-dollar-client" will solve this. Also, if we want to use the "Nemed exported component", then the current '/app/islands/**/[a-zA-Z0-9[-]+. (tsx|ts)' as it is, we could wrap "functions exported with names beginning with a capital letter" in the same way as the default export. There should be no confusion, as utility functions are generally not exported with names beginning with a capital letter, and names beginning with a capital letter can be regarded as function components. |
Oh, I have a feeling that if I use tsconfig's, |
What version of HonoX are you using?
0.1.9
What steps can reproduce the bug?
label > input { ... }
const MyInput = () => <input />
<label><MyInput /></label>
What is the expected behavior?
The CSS rule should be respected and affect the styling of the island component as if you were using the outer tag without an island.
What do you see instead?
HonoX generates a wrapper
<honox-island>
tag that interferes with the CSS parent/child relationship and the CSS rule isn't applied.Additional information
No response
The text was updated successfully, but these errors were encountered: