Question about preview using code in SwiftUI

Hello,

I have a view which have a few controls and preview macro. I replaced preview macro with following code:

struct ContentView_Preview:PreviewProvider{
    static var previews: some View{
        ContentView()
    }
}

after replacement, preview doesn't work properly. plz tell me how can i fix it.

thanks, c00012

@c00012 You typically want to use a preview macro Preview(_:body:) instead of PreviewProvider.

Could you share the content of ContentView and why you are replacing the preview macro?

If I'm right the correct syntax is

struct ContentView_Previews: PreviewProvider

and not

struct ContentView_Preview:PreviewProvider

Note the "s"

Question about preview using code in SwiftUI
 
 
Q