My function has an argument `error: @Composable ((...
# compose
j
My function has an argument
error: @Composable (() -> Unit)? = null
i.e. a rendering lambda of the error or a null. I want to animate that rendering, so I need to postpone "nulling" the error until the hide animation finishes. How can I remember the composable result?
Copy code
Box(
    modifier = Modifier
        .alpha(errorAlpha.value)
) {
    if (error != null) {
        error()
    }
}
This did the trick for me:
Copy code
var errorState by remember { mutableStateOf(error) }
if (error == null) {
    LaunchedEffect(this) {
        delay(AnimationDuration.toLong())
        errorState = null
    }
} else {
    errorState = error
}