disposableRef

fun disposableRef(vararg keys: Any?, effect: DisposableEffectScope.(TElement) -> DisposableEffectResult)(source)

Like ref, but will get triggered both when the element is added to and removed from the DOM.

The callback passed in here must end with an onDispose block, as in:

{
...
onDispose { ... }
}