Skip to content
Bunshi
GitHub

onUnmount

onUnmount(fn): void

Registers a lifecyle callback for when a molecule is released (unmounted).

This lifecycle will be called everytime this molecule that is used for a scope has been released. This helps provide an opportunity to cleanup or stop anything that is internally used.

For example, if your molecule is scoped by some UserScope then onUnmount will be called for when “User A” and “User B” scopes are released.

Parameters

ParameterTypeDescription
fnCleanupCallbackA callback to run when a molecule is unmounted

Returns

void

Source

src/vanilla/lifecycle.ts:79