mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
f53854bd93
This covers most everything. The perf suite still needs work for the Element updates. And the server rendering example needs to be done wholesale.
42 lines
1.1 KiB
JavaScript
42 lines
1.1 KiB
JavaScript
if (typeof exports == 'undefined') exports = {};
|
|
|
|
/*http://benchmarkjs.com/docs#options*/
|
|
|
|
exports.name = 'From setState to callback (x5)';
|
|
|
|
exports.defer = true;
|
|
|
|
exports.setup = function(){
|
|
/*global*/_rootNode = document.createElement('div');
|
|
document.body.appendChild(_rootNode);
|
|
/*global*/setState = null;
|
|
|
|
var AwesomeComponent = React.createClass({
|
|
getInitialState: function(){
|
|
return { random:null };
|
|
},
|
|
render: function(){
|
|
if (!setState) setState = this.setState.bind(this);
|
|
return React.DOM.div(null, this.state.random);
|
|
}
|
|
});
|
|
|
|
React.render(AwesomeComponent(null), _rootNode);
|
|
};
|
|
exports.fn = function(deferred){
|
|
setState({random: Date.now() + Math.random()}, function(){
|
|
setState({random: Date.now() + Math.random()}, function(){
|
|
setState({random: Date.now() + Math.random()}, function(){
|
|
setState({random: Date.now() + Math.random()}, function(){
|
|
setState({random: Date.now() + Math.random()}, function(){
|
|
deferred.resolve();
|
|
});
|
|
});
|
|
});
|
|
});
|
|
});
|
|
};
|
|
exports.teardown = function(){
|
|
React.unmountComponentAtNode(_rootNode);
|
|
};
|