Next.js: React 16.2 <> Fragment

Created on 30 Nov 2017  路  3Comments  路  Source: vercel/next.js

React 16.2 now support a new fragment component, which is great for styled jsx. I think Babel needs an update to use it with next.js as <>.

https://reactjs.org/blog/2017/11/28/react-v16.2.0-fragment-support.html

p0

Most helpful comment

Very cool! Yes, we'll have to wait until next core moves to babel@7.

Unfortunately, support for Babel 6.x is not available, and there are currently no plans to backport.

However, this looks awesome, and we can use <Fragment /> in the meantime, and transform later (from the link you shared):

const Fragment = React.Fragment;

<Fragment>
  <ChildA />
  <ChildB />
  <ChildC />
</Fragment>

// This also works
<React.Fragment>
  <ChildA />
  <ChildB />
  <ChildC />
</React.Fragment>

More info on Babel 7 here: #2654

Thank you for sharing, as I was unaware of this update!

All 3 comments

Very cool! Yes, we'll have to wait until next core moves to babel@7.

Unfortunately, support for Babel 6.x is not available, and there are currently no plans to backport.

However, this looks awesome, and we can use <Fragment /> in the meantime, and transform later (from the link you shared):

const Fragment = React.Fragment;

<Fragment>
  <ChildA />
  <ChildB />
  <ChildC />
</Fragment>

// This also works
<React.Fragment>
  <ChildA />
  <ChildB />
  <ChildC />
</React.Fragment>

More info on Babel 7 here: #2654

Thank you for sharing, as I was unaware of this update!

This issue can be closed.

agreed 馃槃

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lixiaoyan picture lixiaoyan  路  3Comments

renatorib picture renatorib  路  3Comments

jesselee34 picture jesselee34  路  3Comments

ghost picture ghost  路  3Comments

wagerfield picture wagerfield  路  3Comments