Skip to main content

use_effect

Function use_effect 

Source
pub fn use_effect<D, C, M>(cx: &mut Cx<'_, '_>, deps: D, f: impl FnOnce() -> C)
where D: Hash, C: IntoCleanup<M>,
Expand description

Run f on the first visit and whenever the hash of deps changes.

The body runs at the call site, not after the pass, so it can borrow locals and State guards. The cleanup it returns is stored and run before the next body and on unmount.