NavigationView

fun NavigationView(    context: Context,     attrs: AttributeSet? = null,     viewModelStoreOwner: ViewModelStoreOwner = context.toViewModelStoreOwner())

Parameters

viewModelStoreOwner

Defaults to store owner tied to the hosting Activity. If you prefer the lifecycle of the ViewModels internal to NavigationView to be tied to the hosting Fragment instead, provide that Fragment as an argument. Providing a Fragment's store owner allows to achieve tighter memory control if the resources used by the NavigationView shouldn't outlive its hosting Fragment (in anticipation of potential Fragment recreation).