Lambdas are memoized only if everything in it is "...
# compose-android
a
Lambdas are memoized only if everything in it is "stable" , yes? Well, some things like contexts and view models aren't always stable, so those ones don't get remember-ed. Are there any pitfalls to manually doing it?
remember { originalLambda }
I ask only because there's always something in the parent that recomposes it, e.g. Scaffold with scrollBehaviour and innerPadding. Child composables that have such lambdas are unnecessarily recomposing unless I remember them.
(there's only one activity, so there should only be one context throughout, same for viewmodels)
a
You should alway use
remember(capturedValue1, capturedValue2, ...) { lambda }
for correctness.
👍 1