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

Fragment (empty) tag support #137

Open
thescientist13 opened this issue Jan 6, 2024 · 0 comments
Open

Fragment (empty) tag support #137

thescientist13 opened this issue Jan 6, 2024 · 0 comments
Labels
feature New feature or request JSX
Milestone

Comments

@thescientist13
Copy link
Member

Summary

One rule with JSX is that there can only be one top level node in the render tree.

export default class Header extends HTMLElement {

  connectedCallback() {
    this.render();
  }

  render() {
    return (
      <header>
        <nav>...</nav>
      </header>
      <h1>Welcome to my website!</h1>
    );
  }
}

customElements.define('app-header', Header);

Screenshot 2024-01-06 at 12 57 48 PM

Details

The "fragment" wrapping tag convention can effectively act as a pass through tag that wont be part of the rendered output, but helps from a quality of life perspective when authoring JSX

export default class Header extends HTMLElement {

  connectedCallback() {
    this.render();
  }

  render() {
    return (
      <>
        <header>
          <nav>...</nav>
        </header>
        <h1>Welcome to my website!</h1>
      </>
    );
  }
}

customElements.define('app-header', Header);
@thescientist13 thescientist13 added feature New feature or request JSX labels Jan 6, 2024
@thescientist13 thescientist13 added this to the 1.0 milestone Jan 6, 2024
@thescientist13 thescientist13 moved this from 🔖 Ready to 📋 Backlog in [WCC] General Activities Dec 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request JSX
Projects
Status: 📋 Backlog
Development

No branches or pull requests

1 participant