0

How to avoid reloading a fragment when switching to another fragment? Example: I go to the main page, the list is loaded on it, when you switch to another fragment, the list is also loaded in it, when you return to the main page, the list should appear without reloading it.

TriangleN
  • 167
  • 1
  • 1
  • 7
  • Usually, when you navigate to another fragment, your former fragment leaves the composition and therefore will be recomposed when navigating back to it. It is expected behavior. – Steyrix Dec 14 '22 at 09:18
  • Does this answer your question? [Jetpack compose NavHost prevent recomposition screens](https://stackoverflow.com/questions/67583404/jetpack-compose-navhost-prevent-recomposition-screens) – Steyrix Dec 14 '22 at 09:19
  • Use a view model tied to that fragment which stores state of the information collected on that fragment. Something like StateFlow or LiveData can solve this for you – paul_hundal Dec 15 '22 at 18:58

0 Answers0