any ideas on how to add navigation in compose for web
this code block works fine on desktop but on web it just bugs out
Copy code
@OptIn(ExperimentalDecomposeApi::class)
@Composable
fun RouterScreen() {
val router: Router<RouterStateModels> = rememberRouter(RouterStateModels::class) { listOf(Auth) }
RoutedContent(
router = router,
animation = predictiveBackAnimation(
backHandler = LocalRouterContext.current.backHandler,
onBack = { router.pop() },
animation = stackAnimation(slide())
),
) { screen ->
when (screen) {
Auth -> {
AuthScreen(
navigateToHome = {
//Pass the satate of the session to the home screen
router.push(Home)
}
)
}
is Home -> {
HomeScreen()
}
}
}
}
any ideas on how to solve this ?
a
Arkadii Ivanov
01/02/2024, 1:21 PM
Cc: @xxfast
K 1
Arkadii Ivanov
01/02/2024, 2:12 PM
Meantime just to clarify, what variant of Compose for Web you are using - JS HTML, JS Canvas or Wasm? And what is "bugs out"?
y
youssef
01/02/2024, 2:19 PM
I am using the Compose Web that comes with Compose Wizard, by bugs out I mean it freezes I have a LaunchedEffect like so
Copy code
LaunchedEffect(state.isSuccess) {
if (state.isSuccess){
//delay is added to prevent crash
delay(1)
navigateToHome.invoke()
}
}
when the state is successful there is a CircularProgressIndicator for 1ms and then it navigates to home. at least that's what's supposed to happen but the loading freezes and the app freezes with no errors i also added that delay of 1 ms because if I don't it crashes on both desktop and web.
youssef
01/03/2024, 11:06 AM
@Arkadii Ivanov any updates?
a
Arkadii Ivanov
01/03/2024, 11:09 AM
Decompose-Router is maintained by @xxfast. But from the provided information it's not clear what is the cause. Is there any chance for a reproducer?
Arkadii Ivanov
01/03/2024, 11:10 AM
loading freezes
This suggests that there is a general issue in the app. Might be a deadlock due to the single-threaded JS environment, or something like that.