Hacker News new | ask | show | jobs
by lilyball 1840 days ago
Deep nesting suggests that you need to break parts out into their own views (or pull logic out into their own functions). Like the close box in that file, it’s a great candidate for turning into its own view, or at least moving it’s action into a separate function.
1 comments

This! It’s generally a good idea to have a lot of smaller “dumb” views that are stateless and depend on their parameters, and a few “intelligent” views that bring the children together and provide state logic. That puts reasonable boundaries between the view and business logic, even in declarative code like SwiftUI.

I’m not a Swift or SwiftUI expert, but have written declarative UI quite a bit. Don’t imagine some base best practices would differ too much.