0
respostas

Erro ao Adicionar previewLayout

Erro quando adiciona (.previewLayout(.sizeThatFits), descricao do erro a seguir: PreviewLayout is ignored in a #Preview macro. Use the traits argument of the macro to provide the desired layout, e.g. `.sizeThatFitsLayout.

struct OrderTypeGridView: View {
    
    var gridLayout: [GridItem] {
        return Array(repeating: GridItem(.flexible(), spacing: 10), count: 2)
    }
        
    var body: some View {
        LazyHGrid(rows: gridLayout, spacing: 15) {
            ForEach(ordersMock) { orderItem in
                OrderTypeView(orderType: orderItem)
            }
        }.frame(height: 200)
    }
}

#Preview {
    OrderTypeGridView()
        .previewLayout(.sizeThatFits). // Erro quando adicionar esse elemento
}