sycamore::web

Function render_in_scope

pub fn render_in_scope(view: impl FnOnce() -> View, parent: &Node)
Expand description

Render a View under a parent node, in a way that can be cleaned up.

This function is intended to be used for injecting an ephemeral sycamore view into a non-sycamore app (for example, a file upload modal where you want to cancel the upload if the modal is closed).

It is, however, preferable to have a single call to render or render_to at the top level of your app long-term. For rendering a view that will never be unmounted from the dom, use render_to instead. For rendering under the <body> tag, use render instead.

It is expected that this function will be called inside a reactive root, usually created using create_root.