r/javascript • • Sep 26 '17

React 16

https://facebook.github.io/react/blog/2017/09/26/react-v16.0.html
379 Upvotes

63 comments sorted by

83

u/batmansmk Sep 26 '17

It's an impressive release. Here is the gist: Among the changes are some long-standing feature requests, including:

  • fragments,

  • error boundaries,

  • portals,

  • support for custom DOM attributes,

  • improved server-side rendering,

  • reduced file size

  • MIT license,

  • Fiber

22

u/jocull Sep 27 '17

Now you're thinking with portals...?

6

u/Amadox Sep 27 '17

...this coming from a guy who has his reddit-cake-day today... even though we all know, the cake is a lie...

7

u/SomeRandomBuddy Sep 26 '17

Fuck. Great release.

2

u/rottenanon Sep 27 '17

fragments

In the blog they mention, "now you can return an array from render". Wasn't this always the case? :-/

I understand returning from string render is new, but could someone tell me what else is new in fragments?

9

u/Savageman Sep 27 '17

Until now every render needed a single top-level HTML element.

16

u/Skaryon Sep 26 '17

This sounds great. I never used rollup. Will it always yield smaller bundles as opposed to webpack?

31

u/batmansmk Sep 26 '17

Short answer: No.

TL;DR: webpack has more feature for apps, and rollup more for libs. https://medium.com/webpack/webpack-and-rollup-the-same-but-different-a41ad427058c

3

u/Skaryon Sep 26 '17

Haha I just read the same article. Thanks anyway! That answered my question thoroughly.

1

u/Pesthuf Sep 27 '17

But doesn't Webpack do that too?

In the Webpack 3 announcement, they mentioned

 webpack.optimize.ModuleConcatenationPlugin()

which supposedly does the same.

111

u/basically_alive Sep 26 '17

I felt a great disturbance in the Force, as if millions of pointless divs cried out in terror and were suddenly silenced.

28

u/MOON_MOON_MOON Sep 26 '17

Still waiting for the <> </> syntax as a shorthand for a list of children without a parent. It's silly to have to provide key for every element of a statically known list.

11

u/gelezinislokys Sep 26 '17

react-aux

3

u/MOON_MOON_MOON Sep 27 '17

Oh neat, gonna use this for personal projects and continue to spam <span>s all over the place at work.

-13

u/[deleted] Sep 26 '17

So I can find later.

16

u/kylemh Sep 27 '17

You can save comments! 😎

22

u/Phydos Sep 26 '17

Glad they finally addressed those darn SVG attributes.. The smaller filesize is also a nice bonus

22

u/acyrial Sep 26 '17

MIT license! That's big. I wonder what about all products that were about to be rewritten into non-React solutions due to license.

1

u/PM_YOUR_WORST_FEAR Sep 27 '17

Finally!

I'm sick to death of the patents license getting brought up in every discussion about frameworks.

27

u/coldlestat Sep 26 '17

Yes! And everything wrapped in a nicer licence :)

29

u/[deleted] Sep 26 '17

And by nicer they mean "Your company can use this again without your legal dept lighting your project on fire"

-8

u/fogbasket Sep 26 '17

Until FB sues you for infringing their patents.

12

u/DanielFGray Sep 27 '17

Your risk of being sued by FB is no different from using React or not, even before or after the new license.

5

u/ECrispy Sep 26 '17

Without a patent grant that's debatable.

5

u/Jestar342 Sep 26 '17

IANAL: Does there need to be one? What's the default when grant absentia?

1

u/ECrispy Sep 26 '17

There is no default grant.

1

u/Jestar342 Sep 26 '17

No, I'm not asking if there is a default grant, I am asking what is the default legal position in the absence of a grant.

3

u/ECrispy Sep 26 '17 edited Sep 26 '17

It means you can be sued for patent violation if FB so chooses, since they don't grant you any rights.

Its for this reason that GraphQL, which does have explicit patents, was on such shaky ground - https://www.theregister.co.uk/2017/09/20/gitlab_suspends_graphql_project_over_facebook_license_terms/

FB today announced this - https://code.facebook.com/posts/121714468491809/relicensing-the-graphql-specification/

which seems to have taken care of that issue.

9

u/tonechild Sep 26 '17

Anyone know if this works with enzyme?

10

u/UnReaL816 Sep 26 '17

Enzyme was just updated today as well

5

u/tonechild Sep 26 '17

Nice! Thanks!

5

u/alsiola Sep 26 '17

With the new enzyme release (3.0) then yes.

1

u/drom296 Sep 27 '17

so far: upgrading hasn't been smooth.

Upgrading to enzyme@3, requires a new adaptor system. Upgrading to react@16, breaks some other dependencies.

Of course, I'm doing this on a [email protected] project

1

u/tobegiannis Sep 27 '17

Just played around with an upgrade for a few mins. Seems like a pretty clunky way to get enzyme up an running. Do they expect me to import the adapter on every test file or have some kind of useless wrapper?

0

u/[deleted] Sep 27 '17

[deleted]

1

u/gaearon Sep 27 '17

Would be great if somebody could send a PR with this info to CRA user guide!

1

u/tobegiannis Sep 27 '17

Thanks I am not using cra but I stumbled upon a jest config for test startup scripts and got it working.

1

u/toffeescaf Sep 27 '17

Upgrading for me has been a breeze and I'm working on a fairly large project, any specific things you're running into that are a problem?

1

u/drom296 Sep 28 '17

Thanks for the assist. I'll give it another go tomorrow, and PM you if I run into issues again (if that's alright with you)

1

u/toffeescaf Sep 28 '17

That's fine by me. ;)

6

u/nickbreaton Sep 26 '17

Wow portals seem awesome!

5

u/FreshOutBrah Sep 27 '17

Haha love it, "Look ma, no spans!"

3

u/zxia31 Sep 26 '17

Congrats React Team! Great jobs you have achieved.

5

u/swyx Sep 26 '17

this server side rendering is interesting. what does it mean for Next.js?

6

u/eyko Sep 27 '17

Faster Next.js?

2

u/sickcodebruh420 Sep 27 '17 edited Sep 27 '17

Excited to give this a shot. Any TS users fire it up yet? How are the defs looking?

UPDATE: Defs are good! I got some warnings that were easy to clear up. Some libraries need updates. Normal stuff. Build seems faster.

3

u/[deleted] Sep 27 '17

What about react native?

1

u/geritol_ Sep 27 '17

Love the licensing change

-3

u/KebabKo Sep 26 '17

Step 1: Upgrade to React 16 Step 2: Sue facebook Step 3: ? Step 4: Profit!

-1

u/[deleted] Sep 26 '17

That's impressive!

-38

u/fogbasket Sep 26 '17

I'll be that guy. AureliaJS is still better in every way. And you could drop React into it if you wanted to sully it.

11

u/nashio Sep 27 '17

I was looking for that guy. Didn't disappoint

2

u/fogbasket Sep 27 '17

Glad I could be the highlight of someone's day.

2

u/RuthBaderBelieveIt Sep 27 '17

Except ease of hiring devs or finding work.

1

u/fogbasket Sep 27 '17

If you know one framework you can pick up any of them.

1

u/RuthBaderBelieveIt Sep 28 '17

No doubt, but recruiters don't understand that.

1

u/fogbasket Sep 28 '17

I've had the pleasure of speaking with a few that did but you're right. Most recruiters and hiring managers don't understand.

6

u/[deleted] Sep 27 '17

[removed] — view removed comment

5

u/gaearon Sep 27 '17

Hydration = your server gave HTML, and we want to boot up a client up "from" that HTML (and attach events to it) instead of destroying it and rendering from scratch.

3

u/kromit Sep 27 '17

Congratulation on the release :)

Edit: you should do an AMA here one day

3

u/learn_to_model Sep 27 '17 edited Sep 27 '17

Hydration is usually referred to as the process of passing singing data from the server to the client. In this case the server serves the HTML to the client and react can take over the HTML without destroying and recreating it like it was done in the beginning. Hydration can also refer to models bring updated on load with data that has been passed from the server (think of a redux store f.ex.)

3

u/jbkly Sep 27 '17

"passing singing"?

3

u/kylemh Sep 27 '17

Meant signing. Like auth headers I believe.

2

u/learn_to_model Sep 27 '17

Oh shoot, that's my fault. Shouldn't post comments just after I've woken up. What I meant was the process of passing/sending data from the server to the client.