How can I fix the reason why the warning appears?
struct ContentView: View {
@State private var selectedDate: Date = Date()
var body: some View {
Form {
DatePicker("Date", selection: $selectedDate, displayedComponents: .date)
}
}
}
A workaround solution would be to use a
ListView instead of aForm. It all depends on what you want to put in yourForm. For demonstration purpose, using aList, your code would look like this:The above gives the same visual effect (UI) as using a
List, and no warning is shown.Because everything is working correctly with your
Form, I don't really see the need to change yourFormto aListjust to avoid the logs.