Skip to content

Instantly share code, notes, and snippets.

@grrrlikestaquitos
Last active September 24, 2022 17:09
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save grrrlikestaquitos/47aa962204f2f528257b7be5d7518f8a to your computer and use it in GitHub Desktop.
Save grrrlikestaquitos/47aa962204f2f528257b7be5d7518f8a to your computer and use it in GitHub Desktop.
SwiftUI: Higher Order Component Syntax
// Declaring ContainerView as a HOC
struct ContainerView<C: View> : View {
let childView: C
init(_ childView: () -> (C)) {
self.childView = childView()
}
var body: some View {
childView
}
}
// Using ContainerView by passing SwiftUI's Text Component
ContainerView {
Text("Hello There I'm a child component!")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment