I am trying to wrap CodeMirror as a Dioxus component. I am able to get a wasm_bindgen::Closure called whenever there's a change. I'd like to call an EventHandler when that happens. However, calling directly gives a warning that the a writing to a signal happened at render time. I tried to wrap the call to EventHandler in a use_effect but this leads to a panic:
let closure = Closure::wrap(Box::new(move |doc: JsValue| {
use_effect(move || {
on_change.call(doc.as_string().unwrap());
});
}) as Box<dyn FnMut(JsValue)>);
webapp.js:481 panicked at /home/user/.cargo/registry/src/index.crates.io-6f17d22bba15001f/dioxus-core-0.5.6/src/global_context.rs:158:64:
to be in a dioxus runtime