I have a nilable variable, targetLast5Day, and I’m passing it to a sheetView I’m displaying. I’m declaring the variable as nil in the top level, and then assigning a value to it after a button’s click. The problem is the first time I open the Sheet, it somehow considers the variable as nil, however, after the second time, it’s the normal passed value, what’s the issue?
@State private var targetLast5Day: Day? = nil // Mbt4t8l4 mnl mra: `Error`
That’s the button setting value to the targetLast5Day
Button {
targetLast5Day = day
showLast5DaySheet.toggle()
} label: {
CalendarItemMainPageView(passedDay: day)
}
That’s the code for the sheet
.sheet(isPresented: $showLast5DaySheet) {
DaySheetView(passedDay: targetLast5Day != nil ? targetLast5Day! : svm.placeholderDayObj, habitMoved: { habit, to in
handleHabitMove(for: habit, to: to)
})
}




