pub trait UseEffect {
fn use_effect<F, T>(&mut self, func: F)
where
F: FnOnce() -> T,
T: Into<Cleanup>;
}
Expand description
A hook to execute a function once within a component.
Required Methods§
sourcefn use_effect<F, T>(&mut self, func: F)where
F: FnOnce() -> T,
T: Into<Cleanup>,
fn use_effect<F, T>(&mut self, func: F)where
F: FnOnce() -> T,
T: Into<Cleanup>,
Executes the provided func
once (when the component is first rendered), and never again.
The function can optionally return a Cleanup
, which will be run when its parent component
is unmounted.
See also UseEffectWithDeps
.
This is inspired by React’s useEffect
.