camkadev
01/30/2020, 10:19 AMFunctions which invoke @Composable functions must be marked with the @Composable annotation
any workaround to change data (outside Composable) placed inside state?Ian Warwick
01/30/2020, 10:36 AMzhuinden
01/30/2020, 10:40 AM@Composable context to update either a @Model nor a state {camkadev
01/30/2020, 10:45 AM/* TODO here i got: Functions which invoke @Composable functions must be marked with the @Composable annotation*/
@Composable
private val showDialog = state {
false
}
@Composable
fun SomeComposable(){
Button(
"Sign In",
onClick =
/* TODO here i got: Functions which invoke @Composable functions must be marked with the @Composable annotation*/
{
showDialog.value = false
}
)
}Ian Warwick
01/30/2020, 10:53 AM@Composable on that showDialog state variableIan Warwick
01/30/2020, 10:55 AMshowDialog such as private val showDialog by state { false } ? not sure if it works in all contexts but it works for inline variables and means you don't need to showDialog.value = false can simply use showDialog = falsecamkadev
01/30/2020, 11:06 AMcamkadev
01/30/2020, 11:13 AMvar showDialog by state { false } is works, looks like i missed by explanation when readingIan Warwick
01/30/2020, 11:18 AMIan Warwick
01/30/2020, 11:32 AMimport androidx.compose.state
import androidx.ui.core.Text
import androidx.ui.material.Button
val count = state { 0 }
Text(text = "You clicked ${count.value} times")
Button(text = "Click me", onClick = { count.value++ })Ian Warwick
01/30/2020, 11:32 AMIan Warwick
01/30/2020, 11:34 AM