Skip to content

Latest commit

 

History

History
36 lines (21 loc) · 865 Bytes

PATTERNS_BEST_PRACTICES.md

File metadata and controls

36 lines (21 loc) · 865 Bytes

Patterns and Best Practices

Enhance your application's navigation by following these best practices.

1. Use Type-Safe Navigation

Ensure that the data you pass conforms to Hashable.

Example

struct MyData: Hashable {
    let id: UUID
    let name: String
}

2. Keep Navigation Logic Separate

Encapsulate navigation logic within view models or dedicated navigation handlers.

3. Handle Navigation State Carefully

Be mindful of the navigation stack's state to prevent unexpected behavior.

4. Consistent Use of Navigator

Use the Navigator consistently throughout your app to maintain a predictable navigation flow.

5. Avoid Deep Navigation Stacks

Keep your navigation stack shallow to improve performance and user experience.

6. Testing Navigation

Write unit tests for your navigation logic to ensure reliability.