Cannot convert value of type 'some View' to specified type ‘ContentView'

func displayUI () {
let hostingController = UIHostingController(rootView: ContentView(ViewModel: contentViewModal).environmentObject(self))
}

Above code works fine.

I attempted to make the hostingController as instance variable instead of local variable and declared the hostingController outside of display function like this

lazy var hostingController: UIHostingController = UIHostingController(rootView: ContentView())

and so I removed let keyword

func displayUI () {
 hostingController = UIHostingController(rootView: ContentView(ViewModel: contentViewModal).environmentObject(self))
}

Once I remove the let keyword I started getting this error.

Cannot convert value of type 'some View' to specified type ‘ContentView'

Any idea why I am getting this error after removing let keyword declared before hostingController variable?

Cannot convert value of type 'some View' to specified type ‘ContentView'
 
 
Q