I did a comparison of Angular and React and decided to try a performance test to see how quickly the large (ish) list would display in both frames.
When I finished my React prototype with some basic currency formation, it took ~ 2 seconds for my fast laptop. With Angular, this was barely noticeable - only when I switched to my phone did it have a noticeable lag.
This was very surprising because I was told that React should have recaptured Angular's pants for performance, but it seems to be true in this case.
I pushed the prototype into a very simple application to try to isolate the problem: https://github.com/pselden/react-render-test
In this example, it takes almost 200 ms to display this simple list after changing the language, and I am not doing anything.
Am I doing something wrong here?
'use strict'; var React = require('react'), Numbers = require('./Numbers'); var numbers = [] for(var i = 0; i < 2000; ++i){ numbers.push(i); } var App = React.createClass({ getInitialState: function() { return { locale: 'en-US' }; }, _onChangeLocale: function(event) { this.setState({locale: event.target.value}); }, render: function() { var currentLocale = this.state.locale; return ( <div> <select onChange={this._onChangeLocale}> <option value="en-US">English</option> <option value="fr-FR">French</option> </select> <Numbers numbers={numbers} locales={[currentLocale]} /> </div> ); } }); module.exports = App;
'use strict'; var React = require('react'), ReactIntlMixin = require('react-intl'); var Numbers = React.createClass({ mixins: [ReactIntlMixin], getInitialState: function() { return { numbers: this.props.numbers }; }, render: function() { var self = this; var list = this.state.numbers.map(function(number){ return <li key={number}>{number} - {self.formatNumber(number, {style: 'currency', currency: 'USD'})}</li> }); return <ul>{list}</ul>; } }); module.exports = Numbers;
PS: Added Angular version: https://github.com/pselden/angular-render-test
Edit: I discovered the problem with an intl reaction, and we researched and found that there wasn’t too much overhead with https://github.com/yahoo/react-intl/issues/27 - it just Responds to itself that here is slower.
angularjs reactjs
Paul Oct 30 '14 at 16:25 2014-10-30 16:25
source share