Comments (2)
@OptIn(ExperimentalMaterialApi::class)
@Composable
fun NavHostSample() {
val navigator = rememberNavigator()
NavHost(
navigator = navigator,
initialRoute = "/A",
swipeProperties = remember { SwipeProperties() },
) {
scene(route = "/A") {
var count by rememberSaveable { mutableStateOf(0) }
Column(
modifier = Modifier.fillMaxSize(),
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.Center,
) {
Button(onClick = { count++ }) {
Text(text = "count: $count")
}
Button(onClick = { navigator.navigate(route = "/B") }) {
Text(text = "navigate")
}
}
}
scene(route = "/B") {
Column(
modifier = Modifier.fillMaxSize(),
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.Center,
) {
Button(onClick = { navigator.goBack() }) {
Text(text = "goBack")
}
}
}
}
}
以上代码在从A页面导航到B页面再回退到A页面时,count 被重置了
我发现跟这个 swipeProperties
参数有关,当我去掉这个参数时问题消失了
from precompose.
麻烦补全一下复现步骤
如果是:
①:在 A 页面使用rememberSaveable
,导航到 B 页面,调用navigator.goBack()
返回 A 页面,此时我测试rememberSaveable
的行为正常,数据没有被重置,如果发现被重置了麻烦提供能够复现的 sample
②:从 A 页面导航到 B 页面,在 B 页面使用rememberSaveable
,调用navigator.goBack()
返回 A 页面,此时 B 页面rememberSaveable
会被重置,这是预期行为
如果还有别的情况,麻烦补充,最好能够提供最小复现 sample
from precompose.
Related Issues (20)
- Crash when specifying arguments in a group navigation initialRoute HOT 3
- No Koin context has been provided HOT 1
- Navigate back with result HOT 4
- compose desktop 当点击关闭窗口时,NavHost中的内容变成了空白 HOT 6
- navigator.currentEntry的path或者route.route不符合预期 HOT 3
- kotlin.NotImplementedError: An operation is not implemented. HOT 2
- iOS like gesture navigation back UI glitch HOT 3
- Does it support web browser history ? HOT 1
- Very High recomposition with Scene Block HOT 7
- navigator.currentEntry.collectAsStateWithLifecycle always returns null on iOS HOT 5
- iOS crash during backward swipe HOT 6
- Popback Stack with popUpTo HOT 2
- 如何在初始化NavHost的时候 对默认scene 添加launchSingleTop 与 goBack的时候导致页面重组 HOT 11
- Can we pass more complex data classes to screen? HOT 2
- Sample ToDo app crashes with KoinCompose 1.1.2 HOT 1
- Version 1.5.10 breaks animation progress inside screen HOT 2
- invoking goBack will break navigation if nav transitions are used HOT 3
- Deeplinks are not working HOT 3
- Using floating() with SwipeProperties breaks the floatings scenes HOT 1
- Please add support for named route HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from precompose.