[英]How can I use LaunchEffect in the AndroidView in the Jetpack Compose?
You can run the LaunchedEffect only inside a @Composable
function, this means that your lamba should me annotated with @Composable () -> Unit
in order to be compatibile.您只能在
@Composable
function 内运行 LaunchedEffect,这意味着您的 Lamba 应该使用@Composable () -> Unit
进行注释以便兼容。 But I'm not pretty sure that is a good practice.但我不太确定这是一个好习惯。
You are trying to use composable LaunchedEffect not inside composable scope.您正在尝试使用可组合的 LaunchedEffect 不在可组合的 scope 内。 Move launched effect outside of getMapAsync.
将启动效果移到 getMapAsync 之外。
You can do something like.你可以做类似的事情。
@Composable
fun MapViewContainer {
...
var mapIsReady by remember { mutableStateOf(false) }
...
mapView.getMapAsync {
mapIsReady = true
...
}
...
if (mapIsReady) {
// do some compose things
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.