DioxusLabs / dioxus

Fullstack GUI library for web, desktop, mobile, and more.
https://dioxuslabs.com
Apache License 2.0
19.35k stars 740 forks source link

Add VirtualDom::provide_root_context() taking &mut self #2164

Closed JMS55 closed 3 months ago

JMS55 commented 3 months ago

Dioxus 0.5

If I have a VirtualDom stored in another struct ui_root, currently I must use the replace_with crate and do this:

replace_with_or_abort(&mut ui_root.virtual_dom, |virtual_dom| {
    virtual_dom.with_root_context(EcsContext { world })
});
jkelleyrtp commented 3 months ago

Adding this, but just fyi you can use this method today:

virtualdom.runtime().on_scope(ScopeId(0), || provide_root_context(some_ctx));