Seems like using `derivedStateOf` is more superior...
# compose
e
Seems like using
derivedStateOf
is more superior than
remember(value)
given it can reduce the unnecessary recomposition. I wonder is there any downside using
remember { derivedStateOf { value } }
as oppose to
remember(value)
? More elaboration of my question in https://stackoverflow.com/questions/70801388/is-there-downside-replacing-all-remembervalue-with-remember-derivedstateof
👀 2
d
Derived state only works when there's mutable state in the lambda, and it only gets invalidated based on that and nothing else.
You almost always want to use remember in compostable functions and derived state in view models.
There are exceptions of course but that's the general rule.
z
Derived state also does more bookkeeping so if you don't need it, it's more efficient to use a simpler approach.
🙏 1
🙏🏽 1