Question: I'm trying to conditionally hide a `DatePicker` in SwiftUI. However, I'm having any issue with mismatched types:

```
var datePicker = DatePicker($datePickerDate)
if self.showDatePicker {
    datePicker = datePicker.hidden()
}

```

In this case, `datePicker` is a `DatePicker<EmptyView>` type but `datePicker.hidden()` is a `_ModifiedContent<DatePicker<EmptyView>, _HiddenModifier>`. So I cannot assign `datePicker.hidden()` to `datePicker`. I've tried variations of this and can't seem to find a way that works. Any ideas?

**UPDATE**

You can unwrap the `_ModifiedContent` type to get the underlying type using it's `content` property. However, this doesn't solve the underlying issue. The `content` property appears to just be the original, unmodified date picker.

Answer: 
Command-click the view in question and select the Make Conditional option in Beta 5. I did this on one of my views (LiftsCollectionView), and it generated the following:

```
    if suggestedLayout.size.height > 150 {
      LiftsCollectionView()
    } else {
      EmptyView()
    }

```
The following custom modifier works as .hidden() does by both hiding the view and disabling interaction with it.

ViewModifier and View extension func -

```swift
import SwiftUI

fileprivate struct HiddenIfModifier: ViewModifier {
  var isHidden: Bool

  init(condition: Bool) {
    self.isHidden = condition
  }

  func body(content: Content) -> some View {
    content
      // Conditionally changing the parameters of modifiers
      // is more efficient than conditionally applying a modifier
      // (as in Cristina's ViewModifier implementation).
      .opacity(isHidden ? 0 : 1)
      .disabled(isHidden)
  }
}

extension View {
    /// Hides a view conditionally.
    /// - Parameters:
    ///   - condition: Decides if `View` is hidden.
    /// - Returns: The `View`, hidden if `condition` is `true`.
    func hidden(if condition: Bool) -> some View {
        modifier(HiddenIfModifier(condition: condition))
    }
}

```

Use -

```swift
DatePicker($datePickerDate)
  .hidden(if: !self.showDatePicker)

```

Note -
Conditionally applying a modifier is inefficient because swift sees the unmodified and modified views as different types. This causes the view (and it's state) to be destroyed and rebuilt every time the condition changes. This can become an issue for data heavy views like List. Conditionally changing the parameters of modifiers doesn't cause this issue.