forked from facebook/react
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetState-callback-5.js
More file actions
41 lines (35 loc) · 1.14 KB
/
setState-callback-5.js
File metadata and controls
41 lines (35 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
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.renderComponent(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);
};