Conditionally import SwiftUI in README.md example (#138)

This demonstrates portability of Tokamak a bit more in my opinion. Also, we had a redundant closing brace in the example code 🤦‍♂️
This commit is contained in:
Max Desiatov 2020-07-01 14:40:50 +01:00 committed by GitHub
parent 1d71fe0c7d
commit 5adc7b2cff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 1 deletions

View File

@ -34,7 +34,11 @@ Tokamak API attempts to resemble SwiftUI API as much as possible. The main diffe
that you add `import TokamakDOM` instead of `import SwiftUI` in your files:
```swift
#if os(WASI)
import TokamakDOM
#else
import SwiftUI
#endif
struct Counter: View {
@State var count: Int
@ -48,7 +52,7 @@ struct Counter: View {
Text("\(count)")
}
) : AnyView(
VStack { Text("Limit exceeded") } }
VStack { Text("Limit exceeded") }
)
}
}