Skip to main content

Overview

The @Presents macro is used to mark properties that represent optional child feature state in tree-based navigation. It wraps the property with PresentationState and provides observation support when used with the @ObservableState macro. Use this macro instead of the @PresentationState property wrapper when adopting the @ObservableState macro, which is incompatible with property wrappers.

Declaration

Usage

Basic Presentation

Use @Presents to mark optional child state in your feature’s state:

Multiple Destinations with Enum

When supporting multiple presentation destinations, use @Presents with an enum:

Accessing Presented State

The macro provides a projected value (with $ prefix) of type PresentationState:

Key Points

  • Observation Support: Automatically integrates with SwiftUI’s observation system when used with @ObservableState
  • Projected Value: Provides a $ prefixed projected value of type PresentationState
  • Navigation Integration: Works seamlessly with the ifLet reducer operator for tree-based navigation
  • Type Safety: Ensures compile-time safety for optional child state management
  • PresentationState - The underlying property wrapper type
  • PresentationAction - Action wrapper for presented features
  • @ObservableState - Macro for observable state conformance
  • ifLet - Reducer operator for optional state

See Also