Skip to content

Instantly share code, notes, and snippets.

@muankit
Created December 21, 2022 09:48
Show Gist options
  • Save muankit/39912ffb5251ed009ecbc8e2fcc62614 to your computer and use it in GitHub Desktop.
Save muankit/39912ffb5251ed009ecbc8e2fcc62614 to your computer and use it in GitHub Desktop.
Composition Local Provide is not updating child compose if provider value changed at runtime
@Composable
fun ScreenUI() {
val isRtl = if (viewModel.isRtl) {
LocalLayoutDirection provides LayoutDirection.Rtl
} else {
LocalLayoutDirection provides LayoutDirection.Ltr
}
CompositionLocalProvider(isRtl) {
ConstraintLayout(modifier = Modifier.fillMaxSize()) {
// Other compose code
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment