question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Fragment node type to support <></> JSX syntax?

See original GitHub issue
const view = <>
  <h1>{state.count}</h1>
  <button onclick={actions.down}>-</button>
  <button onclick={actions.up}>+</button>
</>

to avoid writing commas in jsx:

const view = [
  <h1>{state.count}</h1>,
  <button onclick={actions.down}>-</button>,
  <button onclick={actions.up}>+</button>,
];

refs:

by the way, returning an array of elements from root view leads to <undefined></undefined> in DOM but nested views are rendered as expected

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:32 (25 by maintainers)

github_iconTop GitHub Comments

9reactions
leeoniyacommented, Jan 6, 2018

i can’t get what’s the problem to just wrap it in sum tag, say <div>

the real problem is not clutter, but allowing isolated (redraw-optimized) components to consist of siblings where the DOM does not allow for arbitary <div> insertion. e.g. you can’t wrap several <tr> or <li> elements in a <div>. similarly, the way flexbox works relies on direct children of flex container elements, so one cannot easily wrap them because it prevents proper grouping/wrapping.

without fragment support, rather than redrawing several adjacent <tr>s in a large recordset, you have to redraw/diff the entire tbody or table.

6reactions
jorgebucarancommented, Jan 6, 2018

Hyperapp already supports returning arrays from components. This issue is just incorrectly titled and I just fixed it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Fragments - React
Fragments let you group a list of children without adding extra nodes to the DOM. There is also a new short syntax for...
Read more >
JSX Fragment Syntax in TypeScript - Marius Schulz
TypeScript 2.6 added support for JSX fragments. ... A fragment lets us group multiple JSX elements without adding an extra wrapper node.
Read more >
Understanding React fragments - LogRocket Blog
Fragments are syntax that allow us to add multiple elements to a React component without wrapping them in an extra DOM node.
Read more >
Documentation - JSX - TypeScript
JSX. JSX is an embeddable XML-like syntax. It is meant to be transformed ... TypeScript supports embedding, type checking, and compiling JSX directly...
Read more >
Blog - Understanding React Fragments (With Examples)
You should use the React Fragment when you want to add a parent element to fulfill the JSX syntax, but without introducing an...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found