Hello! Maybe somebody could help understand why `r...
# compose
d
Hello! Maybe somebody could help understand why
rememberSaveable
doesn’t keep state And what I need to do to fix that
a
It looks like you might be looking for
SaveableStateHolder
?
a
That's actually happens because of using if statement to show composable ... when u use if and use a condition to show some different or multiple composables , the false part will be removed from the composition tree and even remember will be destroyed ... so whenever the condition turns true , the composable go for redraw and recreate not for recompose. At last u have to find another way to show and switch between views like navigations. or if you still want to use conditions ... you can save your states in a viewmodel .. Hope it helps😉
d
@Alex Vanyo yes, it is, thank you 😃
@Alireza Kherazani I was asking about
rememberSaveable
not just
remember
s
What Alireza mentions absolutely applies to rememberSaveable too. Give it a read again, you might understand what they're trying to convey.
a
@Dmitry Motyl That doesn't make any difference ... @Stylianos Gakis Correct , thank you so much 👍
d
Guys, the question was about
rememberSaveable
and what is missing for it to work. And @Alex Vanyo helped very well with it. But thank you for your explanations
a
@Dmitry Motyl That would be so great if you share that with us too plz