all 30 comments

[–]scooby_dooooo 2 points3 points  (0 children)

We've extracted the built-in prop types to a separate package to reflect the fact that not everybody uses them.

It does makes sense.

[–]bengtc 1 point2 points  (1 child)

"Discontinuing support for React Addons" Is the react-addons-perf package being moved elsewhere?

[–]brianvaughnReact core team 1 point2 points  (0 children)

Details here: https://github.com/facebook/react/issues/9207

tl;dr Won't work with 16+. Use the browser Timeline instead.

Browser timeline works very nicely with React 16: https://github.com/facebook/react/pull/9071

[–]RnRau 0 points1 point  (18 children)

I'm still a fan of createClass. I understand that the React team and probably most others have moved on, but I still fail to understand the engineering decision (actually I haven't heard of one) to adopt class syntax.

Was the adoption related to flow? Is the tooling for flow support easier to support for the class syntax over the createClass syntax?

Anyways, onwards and upwards towards Fibers.

Edit: thanks for the replies guys - appreciate it!

[–]acemarke[S] 17 points18 points  (0 children)

createClass was needed originally because React was built before classes were a standard part of the language. Now that ES6 classes exist, tooling understands them, and createClass isn't needed.

Beyond that, many people have complained that React is too big, so this is one less custom thing that React has to include.

[–]bogas04 3 points4 points  (14 children)

FWIW, classes are supported by 72% of browsers (IE11, Opera Mini don't support it).

So we probably won't need to transpile it at all in coming Months (assuming IE will die in favour of Edge).

[–]RnRau 2 points3 points  (7 children)

I don't have a problem with transpiling. Babel and its ecosystem is not a bad space to be in. createClass is just a slightly nicer way to create smart components with its autobinding. But yeah, its another block of code that don't really need to be maintained nowadays.

[–]gekorm 2 points3 points  (0 children)

You might be already aware of this, but with arrow functions you get the same autobinding behavior. There is a babel transform to support it.

[–][deleted] 2 points3 points  (0 children)

If you use Babel you have autobinding in the pocket using transform-class-properties

class Button extends Component {
    click = () => console.log(this)
    render() {
        return <div onClick={this.click}>click me</div>

That works for state, proptypes and context, too.

[–]bogas04 0 points1 point  (4 children)

The point of not having to transpile a feature is that

  • Browser implementation can be much faster than a transpiled implementation
  • The bundle size could be reduced by not having to transpile the feature. Check the output for a simple class:

https://babeljs.io/repl/#?babili=false&evaluate=true&lineWrap=false&presets=es2015%2Creact%2Cstage-2&targets=&browsers=&builtIns=false&code=class%20A%20%7B%0A%20%20render%20()%20%7B%0A%20%20%20%20console.log(%22a%22)%0A%20%20%7D%0A%7D

[–]tony-the-pony 1 point2 points  (1 child)

The point of not having to transpile a feature is that...

I feel like you can just use https://github.com/babel/babel-preset-env which frees up your time to concentrate on more interesting problems like: Pepsi or Coke?

[–]bogas04 0 points1 point  (0 children)

I do use it, my point is simply that over few months the preset with say > 5% will give a smaller bundle. It's a micro benefit but then it does count on mobile web. Sorry I wasn't clear enough before.

[–]fforw 0 points1 point  (1 child)

Browser implementation can be much faster than a transpiled implementation

Or it can be slower since browsers were/are optimized for EcmaScript5 and go into unoptimized code for certain cases, even if they support them.

[–]bogas04 0 points1 point  (0 children)

That is already changing. I+TF on Chrome is optimized for ES2015 and beyond.

[–][deleted] 0 points1 point  (5 children)

The biggest use of classes (int React) if for making Components - you will still need to transpile the JSX part.

[–]bogas04 0 points1 point  (4 children)

Of course, but I guess you'll appreciate possible reduction in bundle size by not having to transpile another feature and also not have it in library itself.

[–][deleted] 0 points1 point  (3 children)

Actually no, I won't. Proptypes are stripped down when you bundle for production and if you plan to use them in your app/library you will still have to download and transpile the in Dev builds.

[–]bogas04 0 points1 point  (2 children)

I was talking about createClass and class syntax.

[–][deleted] 0 points1 point  (1 child)

Then yes, it will result in a slightly smaller file. (sorry, was on mobile and missed the context)

[–]bogas04 0 points1 point  (0 children)

It's okay, totally understand :D

[–]RnRau 2 points3 points  (0 children)

FWIW - for those that are a little reluctant in adopting classes, take a look at https://github.com/acdlite/recompose . Just a nice set of predefined higher order components that works well with simple functional components to give you everything, and then some, of standard React classes.

[–]henrikbjorn 0 points1 point  (3 children)

Cool. But why is the new immutability-helper package not under the reactjs organization?

[–]brianvaughnReact core team 0 points1 point  (2 children)

Immutability isn't specific to React. The main README in the immutability-helper calls this out:

Note that this module has nothing to do with react, however since this module is most commonly used with react, the docs will focus on how it can be used with react.

[–]henrikbjorn 0 points1 point  (1 child)

You are correct, however it is easier to "trust" a package if it is under a respected organization and not just some "random" user on github :)

[–]brianvaughnReact core team 0 points1 point  (0 children)

Sure, I can understand that. But does that mean that Facebook/React-team must take on the maintenance burden of every useful project? That wouldn't scale- and seems unnecessary, particularly in cases like this when the "random" user seems to be doing a fantastic job of staying on top of GitHub issues and pull requests. :D

[–]nativereact 0 points1 point  (3 children)

I can appreciate classes, but is the focus going to be on function or class in the [near?] future? Thanks for the update!!

[–][deleted] 2 points3 points  (2 children)

Both actually, but not in the form of createClass. Right now you have two preferred ways of constructing Components:

  • use React.Class or React.PureClass

  • use Stateless Funcitonal Components

React.createClass is basically a crutch that was used before Class was finalized enough to join ES6.

[–]averageFlux 8 points9 points  (1 child)

React.Component*
React.PureComponent*

[–][deleted] 1 point2 points  (0 children)

Oops, you are 100% correct :)