* clear away prelude on dioxus * clippy * wip - drop prelude from dioxus-html * docs clippy * wip * more fixe * delete all preludes * doc... * better export * merge some imports * fewer global imports * global incremental renderer * fix cargo doc
15 lines
540 B
Rust
15 lines
540 B
Rust
use crate::use_callback;
|
|
use dioxus_core::use_hook;
|
|
use dioxus_signals::Memo;
|
|
|
|
#[doc = include_str!("../docs/derived_state.md")]
|
|
#[doc = include_str!("../docs/rules_of_hooks.md")]
|
|
#[doc = include_str!("../docs/moving_state_around.md")]
|
|
#[track_caller]
|
|
pub fn use_memo<R: PartialEq>(mut f: impl FnMut() -> R + 'static) -> Memo<R> {
|
|
let callback = use_callback(move |_| f());
|
|
let caller = std::panic::Location::caller();
|
|
#[allow(clippy::redundant_closure)]
|
|
use_hook(|| Memo::new_with_location(move || callback(()), caller))
|
|
}
|