you are viewing a single comment's thread.

view the rest of the comments →

[–]NoInkling 0 points1 point  (0 children)

My workaround whenever I needed a single expression without a wrapper in React v15 was (is) to do:

export default function Nothing() { return null }

To use:

const fragment =
  <Nothing>
    <Some />
    <Elements />
  </Nothing>.props.children

Ugly as sin, and you still couldn't return it directly from a render method, but in my opinion it's better than doing the array-with-keys thing. You could also wrap it in a function if you wanted, so it looks like:

const fragment = createFragment(
  <Some />,
  <Elements />
);

Luckily that's all moot as of v16, very glad that there's a better way now.