-
Notifications
You must be signed in to change notification settings - Fork 781
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
Support nodes whose tag is a function. #77
Conversation
This makes it possible to create jsx components in this way: <MyComponent props=...></MyComponent>
Codecov Report@@ Coverage Diff @@
## master #77 +/- ##
==========================================
- Coverage 72.72% 72.41% -0.32%
==========================================
Files 3 3
Lines 143 145 +2
==========================================
+ Hits 104 105 +1
- Misses 39 40 +1
Continue to review full report at Codecov.
|
That's a really nice addition 👏👏 |
Cool! But i believe it would be better to pass if (typeof tag === "function") {
tree = tree || []
data.children = tree
return tag(data, tree)
} So const Foo = (props) =>
<div id={props.id} className={props.cls}>{props.children}</div>
const Foo2 = (props, children) =>
<div id={props.id} className={props.cls}>{children}</div>
const foo = <Foo cls="baz qux" id="hi">
<strong>hello</strong>
</Foo> Because what you proposed is a bit nested/more typing, i believe it would be something like const Foo2 = (ctx) =>
<div id={ctx.props.id} className={ctx.props.cls}>{ctx.children}</div> |
Hm... No, no, nevermind. Kinda like more your approach when rethink it. It is more clean and explicit. const Foo2 = ({ props, children }) =>
<div id={props.id} className={props.cls}>{children}</div> It won't be react compatible directly, but who cares, it is more clean :)) |
Don't know, I like them either way. Current, no-react-compatible is more cleaner. |
This makes it possible to create jsx components in this way: <MyComponent props=...></MyComponent>
HyperApp's architecture is largely based in Flux/Redux and/or the Elm Architecture. There's a single state shared by all the views. Another way to put that, views can't have a local state.
But what about components? The answer is stateless components.
Related
app()
s / component approach / return dom #2