Skip to main content

use_effect

Function use_effect 

Source
pub fn use_effect<F, R, D>(effect: F, deps: D)
where F: FnOnce() -> R + 'static, R: EffectCleanup + 'static, D: EffectDeps,
Expand description

Runs a side effect after this component’s tree has actually been committed, similar to React’s useEffect.

effect runs once after the first successful render, and again whenever deps changes value (compared by equality, not identity). Returning a closure from effect registers it as cleanup, run right before the next execution and when the component is unmounted.

§Panics

Panics if called outside a component() scope, or if the order of hook invocations changes between rebuilds (see use_state).