Last active
April 28, 2023 05:48
-
-
Save thearchetypee/6733dabbe30634dadde2f8115109b398 to your computer and use it in GitHub Desktop.
This file contains 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 ParentComponent() { | |
setContent { | |
ComposeTheme { | |
// A surface container using the 'background' color from the theme | |
Surface(modifier = Modifier.fillMaxSize(), color = MaterialTheme.colors.background) { | |
var dynamicData by remember { | |
mutableStateOf("") | |
} | |
LaunchedEffect(Unit) { | |
delay(3000L) | |
dynamicData = "New Text" | |
} | |
MyComponent(title = dynamicData) | |
} | |
} | |
} | |
} | |
@Composable | |
fun MyComponent(title: String) { | |
var data by remember { mutableStateOf("") } | |
val updatedData by rememberUpdatedState(title) | |
LaunchedEffect(Unit) { | |
delay(5000L) | |
data = updatedData | |
} | |
Text(text = data) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment