RayeW47
06/08/2022, 9:40 AMTextField
param placeholder
gets called many times when the placeholder
in question gets rendered, it gets re-called many many times (18-24, not sure the criteria). is this simply something that just is, or is this a bug/avoidable? i have not been able to find much information on itJonas
06/08/2022, 9:51 AMComposable functions might be re-executed as often as every frame, such as when an animation is being rendered.https://developer.android.com/jetpack/compose/mental-model#recomposition
RayeW47
06/08/2022, 9:56 AMplaceholder
that was not `remember`ed and it would keep calling because it didn't know whether or not to consider that thing to trigger a recomposition (i think?)placeholder = {
val placeholderText = getSomeString()
Text(placeholderText)
}
to
placeholder = {
val placeholderText by remember { mutableStateOf(getSomeString()) }
Text(placeholderText)
}
fixed the issue completelykotlinforandroid
06/08/2022, 2:00 PMZach Klippenstein (he/him) [MOD]
06/08/2022, 2:42 PMmutableStateOf
if you never change the value. In your code remember
{
getSomeString()
}
would be sufficient.