Skip to content

Commit 411419c

Browse files
vjeuxzpao
authored andcommitted
Community round-up #10
1 parent fc67d55 commit 411419c

File tree

3 files changed

+125
-0
lines changed

3 files changed

+125
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
---
2+
title: "Community Round-up #10"
3+
layout: post
4+
author: Vjeux
5+
---
6+
7+
This is the 10th round-up already and React has come quite far since it was open sourced. Almost all new web projects at Khan Academy, Facebook, and Instagram are being developed using React. React has been deployed in a variety of contexts: a Chrome extension, a Windows 8 application, mobile websites, and desktop websites supporting Internet Explorer 8! Language-wise, React is not only being used within JavaScript but also CoffeeScript and ClojureScript.
8+
9+
The best part is that no drastic changes have been required to support all those use cases. Most of the efforts were targeted at polishing edge cases, performance improvements, and documentation.
10+
11+
## Khan Academy - Officially moving to React
12+
13+
[Joel Burget](http://joelburget.com/) announced at Hack Reactor that new front-end code at Khan Academy should be written in React!
14+
15+
> How did we get the rest of the team to adopt React? Using interns as an attack vector! Most full-time devs had already been working on their existing projects for a while and weren't looking to try something new at the time, but our class of summer interns was just arriving. For whatever reason, a lot of them decided to try React for their projects. Then mentors became exposed through code reviews or otherwise touching the new code. In this way React knowledge diffused to almost the whole team over the summer.
16+
>
17+
> Since the first React checkin on June 5, we've somehow managed to accumulate 23500 lines of jsx (React-flavored js) code. Which is terrifying in a way - that's a lot of code - but also really exciting that it was picked up so quickly.
18+
>
19+
> We held three meetings about how we should proceed with React. At the first two we decided to continue experimenting with React and deferred a final decision on whether to adopt it. At the third we adopted the policy that new code should be written in React.
20+
>
21+
> I'm excited that we were able to start nudging code quality forward. However, we still have a lot of work to do! One of the selling points of this transition is adopting a uniform frontend style. We're trying to upgrade all the code from (really old) pure jQuery and (regular old) Backbone views / Handlebars to shiny React. At the moment all we've done is introduce more fragmentation. We won't be gratuitously updating working code (if it ain't broke, don't fix it), but are seeking out parts of the codebase where we can shoot two birds with one stone by rewriting in React while fixing bugs or adding functionality.
22+
>
23+
> [Read the full article](http://joelburget.com/backbone-to-react/)
24+
25+
26+
## React: Rethinking best practices
27+
28+
[Pete Hunt](http://www.petehunt.net/)'s talk at JSConf EU 2013 is now available in video.
29+
30+
<figure><iframe width="600" height="370" src="//www.youtube.com/embed/x7cQ3mrcKaY" frameborder="0" allowfullscreen></iframe></figure>
31+
32+
33+
## Server-side React with PHP
34+
35+
[Stoyan Stefanov](http://www.phpied.com/)'s series of articles on React has two new entries on how to execute React on the server to generate the initial page load.
36+
37+
> This post is an initial hack to have React components render server-side in PHP.
38+
>
39+
> - Problem: Build web UIs
40+
> - Solution: React
41+
> - Problem: UI built in JS is anti-SEO (assuming search engines are still noscript) and bad for perceived performance (blank page till JS arrives)
42+
> - Solution: [React page](https://github.com/facebook/react-page) to render the first view
43+
> - Problem: Can't host node.js apps / I have tons of PHP code
44+
> - Solution: Use PHP then!
45+
>
46+
> [**Read part 1 ...**](http://www.phpied.com/server-side-react-with-php/)
47+
>
48+
> [**Read part 2 ...**](http://www.phpied.com/server-side-react-with-php-part-2/)
49+
>
50+
> Rendered markup on the server:
51+
> <figure>[![](/react/img/blog/react-php.png)](http://www.phpied.com/server-side-react-with-php-part-2/)</figure>
52+
53+
54+
## TodoMVC Benchmarks
55+
56+
Webkit has a [TodoMVC Benchmark](https://github.com/WebKit/webkit/tree/master/PerformanceTests/DoYouEvenBench) that compares different frameworks. They recently included React and here are the results (average of 10 runs in Chrome 30):
57+
58+
- **AngularJS:** 4043ms
59+
- **AngularJSPerf:** 3227ms
60+
- **BackboneJS:** 1874ms
61+
- **EmberJS:** 6822ms
62+
- **jQuery:** 14628ms
63+
- **React:** 2864ms
64+
- **VanillaJS:** 5567ms
65+
66+
[Try it yourself!](http://www.petehunt.net/react/tastejs/benchmark.html)
67+
68+
Please don't take those numbers too seriously, they only reflect one very specific use case and are testing code that wasn't written with performance in mind.
69+
70+
Even though React scores as one of the fastest frameworks in the benchmark, the React code is simple and idiomatic. The only performance tweak used is the following function:
71+
72+
```javascript
73+
/**
74+
* This is a completely optional performance enhancement that you can implement
75+
* on any React component. If you were to delete this method the app would still
76+
* work correctly (and still be very performant!), we just use it as an example
77+
* of how little code it takes to get an order of magnitude performance improvement.
78+
*/
79+
shouldComponentUpdate: function (nextProps, nextState) {
80+
return (
81+
nextProps.todo.id !== this.props.todo.id ||
82+
nextProps.todo !== this.props.todo ||
83+
nextProps.editing !== this.props.editing ||
84+
nextState.editText !== this.state.editText
85+
);
86+
},
87+
```
88+
89+
By default, React "re-renders" all the components when anything changes. This is usually fast enough that you don't need to care. However, you can provide a function that can tell whether there will be any change based on the previous and next states and props. If it is faster than re-rendering the component, then you get a performance improvement.
90+
91+
The fact that you can control when components are rendered is a very important characteristic of React as it gives you control over its performance. We are going to talk more about performance in the future, stay tuned.
92+
93+
## Guess the filter
94+
95+
[Connor McSheffrey](http://conr.me) implemented a small game using React. The goal is to guess which filter has been used to create the Instagram photo.
96+
<figure>[![](/react/img/blog/guess_filter.jpg)](http://guessthefilter.com/)</figure>
97+
98+
99+
## React vs FruitMachine
100+
101+
[Andrew Betts](http://trib.tv/), director of the [Financial Times Labs](http://labs.ft.com/), posted an article comparing [FruitMachine](https://github.com/ftlabs/fruitmachine) and React.
102+
103+
> Eerily similar, no? Maybe Facebook was inspired by Fruit Machine (after all, we got there first), but more likely, it just shows that this is a pretty decent way to solve the problem, and great minds think alike. We're graduating to a third phase in the evolution of web best practice - from intermingling of markup, style and behaviour, through a phase in which those concerns became ever more separated and encapsulated, and finally to a model where we can do that separation at a component level. Developments like Web Components show the direction the web community is moving, and frameworks like React and Fruit Machine are in fact not a lot more than polyfills for that promised behaviour to come.
104+
>
105+
> [Read the full article...](http://labs.ft.com/2013/10/client-side-layout-engines-react-vs-fruitmachine/)
106+
107+
Even though we weren't inspired by FruitMachine (React has been used in production since before FruitMachine was open sourced), it's great to see similar technologies emerging and becoming popular.
108+
109+
## React Brunch
110+
111+
[Matthew McCray](http://elucidata.net/) implemented [react-brunch](https://npmjs.org/package/react-brunch), a JSX compilation step for [Brunch](http://brunch.io/).
112+
113+
> Adds React support to brunch by automatically compiling `*.jsx` files.
114+
>
115+
> You can configure react-brunch to automatically insert a react header (`/** @jsx React.DOM */`) into all `*.jsx` files. Disabled by default.
116+
>
117+
> Install the plugin via npm with `npm install --save react-brunch`.
118+
>
119+
> [Read more...](https://npmjs.org/package/react-brunch)
120+
121+
## Random Tweet
122+
123+
I'm going to start adding a tweet at the end of each round-up. We'll start with this one:
124+
125+
<blockquote class="twitter-tweet"><p>This weekend <a href="https://twitter.com/search?q=%23angular&amp;src=hash">#angular</a> died for me. Meet new king <a href="https://twitter.com/search?q=%23reactjs&amp;src=hash">#reactjs</a></p>&mdash; Eldar Djafarov &#x30C3; (@edjafarov) <a href="https://twitter.com/edjafarov/statuses/397033796710961152">November 3, 2013</a></blockquote>

docs/img/blog/guess_filter.jpg

39.7 KB
Loading

docs/img/blog/react-php.png

41.6 KB
Loading

0 commit comments

Comments
 (0)