Skip to content
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

Children usage #4

Open
brokentone opened this issue Sep 14, 2016 · 2 comments
Open

Children usage #4

brokentone opened this issue Sep 14, 2016 · 2 comments

Comments

@brokentone
Copy link

I think our implementation of children / no children based on void components is overly complex. Rather than two code forks terminating in renders, can we have 1 fork that ensures children is undefined if void element, terminating in a single render?

I also think (though I'm not sure) that undefined children is better than empty array children.

i.e.

    var children;

    // If it's not a void element, check for and map children
    if (!voidElementTags[type]) {
      var JsonMLChildren = JsonML.getChildren(node) || [];
      if (JsonMLChildren) {
        children = JsonMLChildren.map((child, index) => this._visit(child, index, data));
      }
    }

    return React.createElement(type, props, children);
@dcolucci
Copy link

Honestly, I prefer the "return a single var" approach over the dual-return approach, but the latter seems to be preferred in most code I've run into here so I was kinda following that.

@diffcunha
Copy link

I agree with @brokentone 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants