I'm getting this lint error, but when I fix the er...
# compose
c
I'm getting this lint error, but when I fix the error... it still remains. Am I misunderstanding the issue or does the lint check/lint itself have a bug?
b
You need a key as well
c
­čĄö
Oh wait. So remember takes an arg? (TIL)
So is this the intended fix?
Copy code
val sharedVM = remember(navController.currentBackStackEntry) { navController.getBackStackEntry(Screen.LoggedOutScreens.route) }
It does make the error go away. so i suppose so?
Alright. I don't think that was the right thing, because I started getting some stacktrace after just trying to call navController.popBackStack (something about route not found) I went back to just a remember{} without an arg then used `
Copy code
@SuppressLint("UnrememberedGetBackStackEntry")
and everything works as expected. Im sure thi will bite me and maybe Ian will have more insight (or someone else), but since I have a demo for tomorrow I will keep this for now.
c
Can you share more code context around that block of code? Is it in a
composable(...) { }
? If so I believe this is the right approach:
Copy code
composable(...) { navBackStackEntry ->
  val sharedVM = remember(navBackStackEntry) { navController.getBackStackEntry(Screen.LoggedOutScreen.route) }
}
­čĄ× 1
b
Sorry, yes. You need to pass in a key to remember so it updates correctly. Something like what Chris is suggesting is the way to go