rememberTransition
Composable Function
Common
@Composable
public fun <T> rememberTransition(
transitionState: TransitionState<T>,
label: String? = null,
): Transition<T>
Creates a Transition
and puts it in the currentState
of the
provided transitionState
. If the TransitionState.targetState
changes, the Transition
will
change where it will animate to.
Remember: The provided transitionState
needs to be remember
ed.
Compared to updateTransition
that takes a targetState, this function supports a different
initial state than the first targetState. Here is an example:
In most cases, it is recommended to reuse the same transitionState
that is remember
ed, such
that Transition
preserves continuity when targetState
is
changed. However, in some rare cases it is more critical to immediately snap to a state change
(e.g. in response to a user interaction). This can be achieved by creating a new
transitionState
: