Skip to main content

use_cleanup

Function use_cleanup 

Source
pub fn use_cleanup<F>(cleanup: F)
where F: FnOnce() + 'static,
Expand description

Registers a cleanup callback that will be executed when the current hook context is cleared (e.g., when a match arm switches).

This is useful for cleaning up side effects like intervals, timeouts, or subscriptions that are not automatically managed by signals.

The cleanup callback is only registered once on the first render. On subsequent re-renders at the same hook index, this is a no-op.

ยงArguments

  • FnOnce() + 'static - The cleanup callback to execute on context teardown.