Created
March 28, 2022 21:07
-
-
Save halilozercan/d56b2e03545c58c5ed66cc276b5155b0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Composable | |
fun Parent() { | |
Column { | |
var length by remember { mutableStateOf(1) } | |
val stringy by remember { derivedStateOf { { "a".repeat(length) } } } | |
ThingCounter(stringy) | |
Button(onClick = { length++ }) { | |
Text(text = "Change stringy") | |
} | |
} | |
} | |
@SuppressLint("UnrememberedMutableState") | |
@Composable | |
fun ThingCounter(stringy: () -> String) { | |
var count by mutableStateOf(0) | |
Button(onClick = { count++ }) { | |
Text("You've had $count ${stringy()}.") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment