perf: remove global allocation for props
This commit is contained in:
1 parent
369b36b2c6
commit
8b3ac0b57c
15 files changed
+352
-105
No files matched your search
@@ -1 +1,43 @@
|
||||
//! Tests for the lifecycle of components.
|
||||
|
||||
use std::{cell::RefCell, rc::Rc};
|
||||
|
||||
use anyhow::{Context, Result};
|
||||
use dioxus::prelude::*;
|
||||
use dioxus_core as dioxus;
|
||||
use dioxus_html as dioxus_elements;
|
||||
mod test_logging;
|
||||
|
||||
const IS_LOGGING_ENABLED: bool = true;
|
||||
type Shared<T> = Rc<RefCell<T>>;
|
||||
|
||||
#[test]
|
||||
fn manual_diffing() {
|
||||
#[derive(PartialEq, Props)]
|
||||
struct AppProps {
|
||||
value: Shared<&'static str>,
|
||||
}
|
||||
|
||||
static App: FC<AppProps> = |cx| {
|
||||
let val = cx.value.borrow();
|
||||
cx.render(rsx! { div { "{val}" } })
|
||||
};
|
||||
|
||||
test_logging::set_up_logging(IS_LOGGING_ENABLED);
|
||||
|
||||
let mut value = Rc::new(RefCell::new("Hello"));
|
||||
let mut dom = VirtualDom::new_with_props(
|
||||
App,
|
||||
AppProps {
|
||||
value: value.clone(),
|
||||
},
|
||||
);
|
||||
|
||||
let _ = dom.rebuild();
|
||||
|
||||
*value.borrow_mut() = "goodbye";
|
||||
|
||||
let edits = dom.diff();
|
||||
|
||||
log::debug!("edits: {:?}", edits);
|
||||
}
|
||||
Reference in new issue
Block a user