React.js Conf Round-up 2015

February 18, 2015 by Steven Luscher


It was a privilege to welcome the React community to Facebook HQ on January 28–29 for the first-ever React.js Conf, and a pleasure to be able to unveil three new technologies that we've been using internally at Facebook for some time: GraphQL, Relay, and React Native.

The talks

Keynote #

Tom Occhino opened with a history of how React came to be, before announcing Facebook’s answer to a long-looming what-if question: what if we could use React to target something other than the DOM?

Tweaking in real time #

Brenton Simpson showed us how eBay brings Bret Victor’s feedback loop to your favorite editor using webpack, react-hot-loader, and Ambidex.

Abstract Syntax Trees #

Gurdas Nijor showed us how we can leverage some conventions of React to perform source code transformations that unlock an inspirational set of use cases.

Relay and GraphQL #

Daniel Schafer and Jing Chen showed us how Facebook approaches data fetching with React, giving us an early peek at the forthcoming duo of Relay and GraphQL.

Channels #

James Long explores what might happen if we introduce channels, a new style of coordinating actions, to React.

React Router #

Michael Jackson reminded us that URLs should be part of our design process, and showed us how react-router can help to manage the transitions between them.

Full-stack Flux #

Pete Hunt showed us how a Flux approach can help us scale actions and questions on the backend in addition to the frontend.

High-performance #

Jason Bonta showed us how complex user interfaces can get, and how his team keeps them performant as they scale. He also had the pleasure of open-sourcing his team’s work on FixedDataTable.

FormatJS and react-intl #

Eric Ferraiuolo showed how you can bring your app to a worldwide audience using a series of polyfills and emerging ECMAScript APIs.

Hype! #

Ryan Florence showed us how easy it is to transition from a career selling life insurance, to a burgeoning one as a software developer. All you have to do is to learn how to say “yes.”

React Native #

Christopher Chedeau showed us how to bring the developer experience of working with React on the web to native app development, using React Native.

Components #

Andrew Rota explained how React and Web Components can work together, and how to avoid some common pitfalls.

Immutability #

Lee Byron led a master-class on persistent immutable data structures, showing us the world of possibility that they can unlock for your software, and perhaps JavaScript in general.

Beyond the DOM #

Jafar Husain told us a story about how Netflix was able to push React into places where the DOM could not go.

Data Visualization #

Zach Nation showed us how we can produce visualizations from over 45 million data points without breaking a sweat.

React Refracted #

David Nolen gave us a view of React from a non-JavaScript perspective, challenging some common intuition along the way.

Flux Panel #

Bill Fisher coordinated a Flux panel together with Michael Ridgway, Spike Brehm, Andres Suarez, Jing Chen, Ian Obermiller, and Kyle Davis.

Component communication #

Bonnie Eisenman led us through the ‘adapter’ approach to inter-component communication taken by her team at Codecademy.

Flow and TypeScript #

James Brantly demonstrated how we can reap the benefits of static typing using both Flow and TypeScript.

Core Team Q&A #

Tom Occhino, Ben Alpert, Lee Byron, Christopher Chedeau, Sebastian Markbåge, Jing Chen, and Dan Schafer closed the conference with a Q&A session.

Reactions

The conference is over, but the conversation has just begun.

Mihai Parparita detailed his efforts to hack his way to a React.js Conf ticket; James Long blogged about his first encounter with React Native; Eric Florenzano talked about how he perceives the impact of Relay, GraphQL, and React Native on software development; Margaret Staples blogged about her experience of being on-campus at Facebook HQ; Jeff Barczewski tied his experience of attending the conference up with a bow in this blog post filled with photos, videos, and links; Kevin Old left us with his takeaways; Paul Wittmann found React Native freshly on his radar; and finally, undeterred by not being able to attend the conference in person, Justin Ball summarized it from afar.

And, in case you missed a session, you can borrow Michael Chan’s drawings, Mihai Parparita’s summary, or Shaohua Zhou’s day 1 / day 2 notes.

All proceeds from React.js Conf 2015 were donated to the wonderful programs at code.org. These programs aim to increase access to the field of computer science by underrepresented members of our community. Watch this video to learn more.

React v0.13.0 Beta 1

January 27, 2015 by Sebastian Markbåge


React 0.13 has a lot of nice features but there is one particular feature that I'm really excited about. I couldn't wait for React.js Conf to start tomorrow morning.

Maybe you're like me and staying up late excited about the conference, or maybe you weren't one of the lucky ones to get a ticket. Either way I figured I'd give you all something to play with until then.

We just published a beta version of React v0.13.0 to npm! You can install it with npm install react@0.13.0-beta.1. Since this is a pre-release, we don't have proper release notes ready.

So what is that one feature I'm so excited about that I just couldn't wait to share?

Plain JavaScript Classes!!

JavaScript originally didn't have a built-in class system. Every popular framework built their own, and so did we. This means that you have a learn slightly different semantics for each framework.

We figured that we're not in the business of designing a class system. We just want to use whatever is the idiomatic JavaScript way of creating classes.

In React 0.13.0 you no longer need to use React.createClass to create React components. If you have a transpiler you can use ES6 classes today. You can use the transpiler we ship with react-tools by making use of the harmony option: jsx --harmony.

ES6 Classes

class HelloMessage extends React.Component {
  render() {
    return <div>Hello {this.props.name}</div>;
  }
}

React.render(<HelloMessage name="Sebastian" />, mountNode);

The API is mostly what you would expect, with the exception of getInitialState. We figured that the idiomatic way to specify class state is to just use a simple instance property. Likewise getDefaultProps and propTypes are really just properties on the constructor.

export class Counter extends React.Component {
  constructor(props) {
    super(props);
    this.state = {count: props.initialCount};
  }
  tick() {
    this.setState({count: this.state.count + 1});
  }
  render() {
    return (
      <div onClick={this.tick.bind(this)}>
        Clicks: {this.state.count}
      </div>
    );
  }
}
Counter.propTypes = { initialCount: React.PropTypes.number };
Counter.defaultProps = { initialCount: 0 };

ES7+ Property Initializers

Wait, assigning to properties seems like a very imperative way of defining classes! You're right, however, we designed it this way because it's idiomatic. We fully expect a more declarative syntax for property initialization to arrive in future version of JavaScript. It might look something like this:

// Future Version
export class Counter extends React.Component {
  static propTypes = { initialCount: React.PropTypes.number };
  static defaultProps = { initialCount: 0 };
  state = { count: this.props.initialCount };
  tick() {
    this.setState({ count: this.state.count + 1 });
  }
  render() {
    return (
      <div onClick={this.tick.bind(this)}>
        Clicks: {this.state.count}
      </div>
    );
  }
}

This was inspired by TypeScript's property initializers.

Autobinding

React.createClass has a built-in magic feature that bound all methods to this automatically for you. This can be a little confusing for JavaScript developers that are not used to this feature in other classes, or it can be confusing when they move from React to other classes.

Therefore we decided not to have this built-in into React's class model. You can still explicitly prebind methods in your constructor if you want.

class Counter extends React.Component {
  constructor() {
    super();
    this.tick = this.tick.bind(this);
  }
  tick() {
    ...
  }
  ...
}

However, when we have the future property initializers, there is a neat trick that you can use to accomplish this syntactically:

class Counter extends React.Component {
  tick = () => {
    ...
  }
  ...
}

Mixins

Unfortunately, we will not launch any mixin support for ES6 classes in React. That would defeat the purpose of only using idiomatic JavaScript concepts.

There is no standard and universal way to define mixins in JavaScript. In fact, several features to support mixins were dropped from ES6 today. There are a lot of libraries with different semantics. We think that there should be one way of defining mixins that you can use for any JavaScript class. React just making another doesn't help that effort.

Therefore, we will keep working with the larger JS community to create a standard for mixins. We will also start designing a new compositional API that will help make common tasks easier to do without mixins. E.g. first-class subscriptions to any kind of Flux store.

Luckily, if you want to keep using mixins, you can just keep using React.createClass.

Note:

The classic React.createClass style of creating classes will continue to work just fine.

Other Languages!

Since these classes are just plain old JavaScript classes, you can use other languages that compile to JavaScript classes, such as TypeScript.

You can also use CoffeeScript classes:

div = React.createFactory 'div'

class Counter extends React.Component
  @propTypes = initialCount: React.PropTypes.number
  @defaultProps = initialCount: 0

  constructor: (props) ->
    super props
    @state = count: props.initialCount

  tick: =>
    @setState count: @state.count + 1

  render: ->
    div onClick: @tick,
      'Clicks: '
      @state.count

You can even use the old ES3 module pattern if you want:

function MyComponent(initialProps) {
  return {
    state: { value: initialProps.initialValue },
    render: function() {
      return <span className={this.state.value} />
    }
  };
}

React.js Conf Diversity Scholarship

December 19, 2014 by Paul O’Shannessy


Today I'm really happy to announce the React.js Conf Diversity Scholarship! We believe that a diverse set of viewpoints and opinions is really important to build a thriving community. In an ideal world, every part of the tech community would be made up of people from all walks of life. However the reality is that we must be proactive and make an effort to make sure everybody has a voice. As conference organizers we worked closely with the Diversity Team here at Facebook to set aside 10 tickets and provide a scholarship. 10 tickets may not be many in the grand scheme but we really believe that this will have a positive impact on the discussions we have at the conference.

I'm really excited about this and I hope you are too! The full announcement is below:


The Diversity Team at Facebook is excited to announce that we are now accepting applications for the React.js Conf scholarship!

Beginning today, those studying or working in computer science or a related field can apply for an all-expense paid scholarship to attend the React.js Conf at Facebook’s Headquarters in Menlo Park, CA on January 28 & 29, 2015. React opens a world of new possibilities such as server-side rendering, real-time updates, different rendering targets like SVG and canvas. Join us at React.js Conf to shape the future of client-side applications! For more information about the React.js conference, please see the website and previous updates on our blog.

At Facebook, we believe that anyone anywhere can make a positive impact by developing products to make the world more open and connected to the people and things they care about. Given the current realities of the tech industry and the lack of representation of communities we seek to serve, applicants currently under-represented in Computer Science and related fields are strongly encouraged to apply. Facebook will make determinations on scholarship recipients in its sole discretion. Facebook complies with all equal opportunity laws.

To apply for the scholarship, please visit the Application Page: https://www.surveymonkey.com/s/XVJGK6R

Award Includes

  • Paid registration fee for the React.js Conf January 28 & 29th at Facebook’s Headquarters in Menlo Park, CA
  • Paid travel and lodging expenses
  • Additional $200 meal stipend

Important Dates

  • Monday, January 5, 2015: Applications for the React.js Conf Scholarship must be submitted in full
  • Friday, January 9, 2015: Award recipients will be notified by email of their acceptance
  • Wednesday & Thursday, January 28 & 29, 2015: React.js Conf

Eligibility

  • Must currently be studying or working in Computer Science or a related field
  • International applicants are welcome, but you will be responsible for securing your own visa to attend the conference
  • You must be available to attend the full duration of React.js conf on January 28 and 29 at Facebook Headquarters in Menlo Park

React v0.12.2

December 18, 2014 by Paul O’Shannessy


We just shipped React v0.12.2, bringing the 0.12 branch up to date with a few small fixes that landed in master over the past 2 months.

You may have noticed that we did not do an announcement for v0.12.1. That release was snuck out in anticipation of Flow, with only transform-related changes. Namely we added a flag to the jsx executable which allowed you to safely transform Flow-based code to vanilla JS. If you didn't update for that release, you can safely skip it and move directly to v0.12.2.

The release is available for download from the CDN:

We've also published version 0.12.2 of the react and react-tools packages on npm and the react package on bower. 0.12.1 is also available in the same locations if need those.

Please try these builds out and file an issue on GitHub if you see anything awry.

Changelog

React Core

  • Added support for more HTML attributes: formAction, formEncType, formMethod, formTarget, marginHeight, marginWidth
  • Added strokeOpacity to the list of unitless CSS properties
  • Removed trailing commas (allows npm module to be bundled and used in IE8)
  • Fixed bug resulting in error when passing undefined to React.createElement - now there is a useful warning

React Tools

  • JSX-related transforms now always use double quotes for props and displayName

Community Round-up #24

November 25, 2014 by Steven Luscher


Keep it Simple

Pedro Nauck (pedronauck) delivered an impeccably illustrated deck at Brazil's Front in Floripa conference. Watch him talk about how to keep delivering value as your app scales, by keeping your development process simple.

Murilo Pereira (mpereira) tussles with the topic of complexity in this blog post about coping with scaling up, where he describes how his team used React to make possible the “nearly impossible.”

I (steveluscher) spoke at Manning Publications' “Powered By JavaScript” Strangeloop pre-conf in St. Louis. There, I proposed a new notation to talk about development complexity – Big-Coffee Notation ☕(n) – and spoke about the features of React that help keep our Big-Coffee from going quadratic, as our user interfaces get more complex.

James Pearce (jamesgpearce) carried Big-Coffee all the way to Raleigh, NC. At the All Things Open conference, he spoke about some of the design decisions that went into React, particularly those that lend themselves to simpler, more reliable code.

All About Isomorphism

Michael Ridgway (mridgway) shows us how Yahoo! (who recently moved Yahoo! Mail to React) renders their React+Flux application, server-side.

Péter Márton (hekike) helps us brew a cold one (literally) using an application that's server-client isomorphic and indexable. Demo and sample code included – cold ones sold separately.

And, lest you think that client-server isomorphism exists in pursuit of crawalable, indexable HTML alone, watch as Nate Hunzaker (nhunzaker) server renders data visualizations as SVG with React.

React Router Mows the Lawn

Ryan Florence (rpflorence) and Michael Jackson (mjackson) unveiled a new API for React Router that solves some of its user's problems by eliminating the problems themselves. Read all about what React Router learned from its community of users, and how they've rolled your ideas into their latest release.

React in Practice

Jonathan Beebe (somethingkindawierd) spoke about how he uses React to build tools that deliver hope to those trying to make the best of a bad situation. Watch his talk from this year's Nodevember conference in Nashville

If you take a peek under the covers, you'll find that React powers Carousel, Dropbox's new photo and video gallery app.

We enjoyed a cinematic/narrative experience with this React-powered, interactive story by British author William Boyd. Dive into “The Vanishing Game” and see for yourself.

Be Kind, Rewind

Spend the next 60 seconds watching Daniel Woelfel (dwwoelfel) serialize a React app's state as a string, then deserialize it to produce a working UI. Read about how he uses this technique to reproduce bugs reported to him by his users.

Community Components

Tom Chen (tomchentw) brings us a react-google-maps component, and a way to syntax highlight source code using Prism and the react-prism component, for good measure.

Jed Watson (jedwatson) helps you manage touch, tap, and press events using the react-tappable component.

To find these, and more community-built components, consult the React Components and React Rocks component directories. React Rocks recently exceeded one-hundred listed components and counting. See one missing? Add the keyword react-component to your package.json to get listed on React Components, and submit a link to React Rocks.

Waiter, There's a CSS In My JavaScript

The internet is abuzz with talk of styling React components using JavaScript instead of CSS. Christopher Chedeau (vjeux) talks about some of the fundamental style management challenges we grapple with, at Facebook scale. A number of implementations of JavaScript centric style management solutions have appeared in the wild, including the React-focused react-style.

Test Isolation

Yahoo! shows us how they make use of iframe elements to unit test React components in isolation.

You've Got The Hang of Flux, Now Let's Flow

Facebook Open Source released Flow this month – a static type checker for JavaScript. Naturally, Flow supports JSX, and you can use it to type check React applications. There's never been a better reason to start making use of propTypes in your component specifications!

Countdown to React.js Conf 2014

We're counting down the days until React.js Conf at Facebook's headquarters in Menlo Park, California, on January 28th & 29th, 2015. Thank you, to everyone who responded to the Call for Presenters. Mark the dates; tickets go on sale in three waves: at noon PST on November 28th, December 5th, and December 12th, 2014.

React Meetups Around the World