-
-
Notifications
You must be signed in to change notification settings - Fork 112
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ambiguous reference to member 'node' #68
Comments
Hi @tgdn! Thank you so much for reporting this and I'm so sorry for the example snippet in README not having working code. I will update it right away. Here's the version that should work: struct Counter: LeafComponent {
struct Props: Equatable {
let countFrom: Int
}
static func render(props: Props, hooks: Hooks) -> AnyNode {
let count = hooks.state(props.countFrom)
return StackView.node(.init(
Edges.equal(to: .parent),
axis: .vertical,
distribution: .fillEqually), [
Button.node(Button.Props(
onPress: Handler { count.set { $0 + 1 } },
text: "Increment"
)),
Label.node(.init(alignment: .center, text: "\(count.value)"))
])
}
} Please bear in mind that macOS renderer supports only a few basic components (compared to iOS renderer, which allows building pretty complex apps), but I'm currently working on adding support for more components in the next version. Also, you'll need to create a view controller that renders your component: import TokamakAppKit
final class ViewController: TokamakViewController {
override var node: AnyNode {
return View.node(
.init(Style([
Edges.equal(to: .parent),
Width.equal(to: 200),
Height.equal(to: 100),
])),
Counter.node(.init(countFrom: 1))
)
}
} The best way to try Tokamak on both iOS and macOS is to clone the repository and run |
I've just added detailed steps for running the Example project to README, please feel free to reopen the issue and report any other problems. Thanks again! |
Thanks for the quick reply. That fixed the issue. |
Copied the example from the README using macOs TokamakAppKit (version 0.1).
macOS 10.14
Xcode 10.1
The text was updated successfully, but these errors were encountered: