Tash
06/16/2021, 5:43 PMMutableState<T>
as arguments:
@Composable fun FooButton(fooState: MutableState<Foo>) { /** read/write fooState here **/ }
instead of accepting the raw data (i.e. not MutableState
) + a lambda for the caller to implement:
@Composable fun FooButton(foo: Foo, onClick: () -> Unit) { /** read foo & call onClick() here **/ }
Given the guidelines around state-hoisting for reads/writes, the former looks like an anti-pattern in the declarative/Compose world. Is that right?Zach Klippenstein (he/him) [MOD]
06/16/2021, 6:00 PMTash
06/16/2021, 6:10 PMbrandonmcansh
06/16/2021, 6:47 PM