-
Q: Is it currently possible to not server-side render the contents of an ContextI'm currently having trouble migrating an app from 0.6 to 0.7 due to multiple reasons which I'm slowly narrowing down on. But one of these issues is a whackamole of hydration errors. I believe this section of the book discusses the underlying issue I have because I'm being very liberal embedding html inside mathml and vice versa to produce a UI which looks and behaves correctly in major browsers despite not being standard compliant. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Sure! Here's an example of a client-only island. (Or a client-only anything to be honest. The trick is that an #[island]
pub fn ClientOnlyIsland() -> impl IntoView {
let render = RwSignal::new(false);
Effect::new(move |_| render.set(true));
move || {
render.get().then(|| {
view! {
<h2>"Client-Only Island"</h2>
}
})
}
} |
Beta Was this translation helpful? Give feedback.
-
Although to add a second answer 😄
Whether it's standard compliant or not isn't actually relevant, per se — What matters is whether the browser renders the DOM elements in the same order that you wrote them. (Which it often doesn't for nonstandard things.) So if it looks and feels right in the browser, you can use the DOM inspector to see how the browser arranges the elements and then arrange them that way in your application and it should be fine, if that's the issue. |
Beta Was this translation helpful? Give feedback.
Sure! Here's an example of a client-only island. (Or a client-only anything to be honest. The trick is that an
Effect
only runs on the client, and that it runs after hydration, so you can mutate a signal in anEffect
and use it to say "only show this on the client.")