## cloneElement You'll sometimes use React's `cloneElement` to provide additonal attributes to a child component - i.e, to add an event handler, className, etc. You can achieve similar behaviour in SwiftUI. ### React ```jsx import React from "react"; export function PageElement() { return (
This is the page content
); } export function LayoutElement({ children }) { return (
This is the layout {React.cloneElement(children, { style: { fontWeight: "bold", fontSize: "2rem" } })}
); } ``` ### Swift ```swift import SwiftUI struct PageElement : View { var body: some View { LayoutElement() { Text("This is the page content") } } } struct LayoutElement : View { var content: () -> Text var body: some View { VStack { Text("This is the layout") content() .bold() .font(.largeTitle) } } } ```