mirror of
https://github.com/facebook/react.git
synced 2026-02-26 18:58:05 +00:00
38 lines
842 B
JavaScript
38 lines
842 B
JavaScript
if (typeof exports === 'undefined') {
|
|
exports = {};
|
|
}
|
|
|
|
/*http://benchmarkjs.com/docs#options*/
|
|
|
|
exports.name = 'From setState to callback';
|
|
|
|
exports.defer = true;
|
|
|
|
exports.setup = function() {
|
|
_rootNode = document.createElement('div');
|
|
document.body.appendChild(_rootNode);
|
|
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() {
|
|
deferred.resolve();
|
|
});
|
|
};
|
|
exports.teardown = function() {
|
|
React.unmountComponentAtNode(_rootNode);
|
|
};
|