Hacker News new | ask | show | jobs
by busymom0 1839 days ago
For those who have used both Flutter and SwiftUI, did you ever find that deep nesting to be very ugly and strange?
1 comments

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.
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.