How does one navigate screens controlled by bottom...
# compose
t
How does one navigate screens controlled by bottom navigation and the bottom nav is in a screen in NavHost. The documentation it's pretty vague in this aspect. They implement a NavHost wc results in ViewModelStore should be set before setGraph call Exception
i
he bottom nav is in a screen in NavHost.
This doesn't make that much sense - generally the bottom nav is outside of the
NavHost
, which is what the docs show. What are you trying to accomplish?
We've seen one issue with that exception, but it was with someone nesting one
NavHost
within another
NavHost
but reusing the same
NavController
instance (you can't do that: each level needs its own
NavController
)
t
@Ian Lake So I setup the main screen (in MainActivity) with NavHost wc wraps whole app. The idea it's to navigate to another screen wc has bottom nav. In docs, I saw another NavHost inside the screen hosting bottom nav. But the thing is, if I do that, setGraph exception is raised.
i
That's absolutely not what the docs do at all - can you link to where you think it is doing that? We always recommend a single NavHost, where you hide and show your bottom nav based on what destination you are on
t
@Ian Lake Maybe I read wrong. I put NavHost at a higher level 😅, instead of Nav controller
464 Views