-
Notifications
You must be signed in to change notification settings - Fork 59
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
Remove elementClasses warning from Fragment #375
Conversation
Hey @bryceosterhaus, I'm fine with this, just a bit confused about the statement
How does that look like? As far as I understood |
An example of intentionally wanting to add elementClasses to the first child would be. Fragment does only render its children, however, class Dropdown extends Component {
render() {
return (
<Fragment>
<button>Show Menu</button>
{this.props.active && (
<ul>
<li>one</li>
<li>two</li>
<li>three</li>
</ul>
)}
</Fragment>
);
}
}
<Dropdown elementClasses="blue-button" />
// renders
// <button class="blue-button">Show Menu</button> |
I see, @bryceosterhaus! So, for <Dropdown elementClasses="blue-button" active={true} />
// We expect
// <button class="blue-button">Show Menu</button>
// <ul>
// <li>one</li>
// <li>two</li>
// <li>three</li>
// </ul> But if class Dropdown extends Component {
render() {
return (
<Fragment>
{this.props.active && (
<ul>
<li>one</li>
<li>two</li>
<li>three</li>
</ul>
)}
<button>Show Menu</button>
</Fragment>
);
}
} You'd then expect <Dropdown elementClasses="blue-button" active={true} />
// We expect
// <ul class="blue-button">
// <li>one</li>
// <li>two</li>
// <li>three</li>
// </ul>
// <button>Show Menu</button>
<Dropdown elementClasses="blue-button" />
// We expect
// <button class="blue-button">Show Menu</button> Does that match your expectations? |
Yeah, that's what I would expect. I think we should note this in the Fragment docs. |
I find this behaviour a bit confusing... 🤔 Maybe inside @brunobasto, would this have any effect on you? |
No, I think it should be fine for me. |
@bryceosterhaus, @mthadley, as you guys are the main users of it, and @brunobasto has no objections at this point... If you think it's fine as it is, could you please add a note of this behaviour in https://github.com/metal/metal.js/blob/master/packages/metaljs.com/src/pages/docs/guides/jsx-components.md#fragment- so we can have it documented at the time of merging? Thanks! |
I think this needs to be removed because it's not always consistent and really annoying when you intentionally want to have elementClasses added to the first child element. If anything, this should be added to documentation instead.