Fixed basic-jsx example, which got clobbered during a prior bug investigation
Jim committed
Jul 17, 2015 at 14:42 UTC
c84489918754e1a4a9387b650b5bb7900bc174e4
1 file changed
+15
-46
examples/basic-jsx/index.html
+15
-46
@@ -29,54 +29,23 @@
29
<script src="../../build/react.js"></script>
30
<script src="../../build/JSXTransformer.js"></script>
31
<script type="text/jsx">
32
+ var ExampleApplication = React.createClass({
33
+ render: function() {
34
+ var elapsed = Math.round(this.props.elapsed / 100);
35
+ var seconds = elapsed / 10 + (elapsed % 10 ? '' : '.0' );
36
+ var message =
37
+ 'React has been successfully running for ' + seconds + ' seconds.';
38
33
-var Top = React.createClass({
34
- childContextTypes: {
35
- now: React.PropTypes.any
36
- },
37
-
38
- getChildContext: function() {
39
- return {
40
- now: this.state.now
41
- };
42
- },
43
-
44
- getInitialState: function() {
45
- return {
46
- now: Date.now()
47
- };
48
- },
49
-
50
- componentDidMount: function() {
51
- setInterval(function() {
52
- this.setState({
53
- now: Date.now()
39
+ return <p>{message}</p>;
40
+ }
41
});
55
- }.bind(this), 500);
56
- },
57
-
58
- render: function() {
59
- return (
60
- <div>
61
- <h1>{this.state.now}</h1>
62
- <Child />{this.props.children}
63
- </div>
64
- );
65
- }
66
-});
67
-
68
-var Child = React.createClass({
69
- contextTypes: {
70
- now: React.PropTypes.any
71
- },
72
-
73
- render: function() {
74
- // I never update
75
- return <h2>{this.context.now}</h2>;
76
- }
77
-});
78
-
79
-React.render(<Top><Child/></Top>, document.getElementById('container'));
42
+ var start = new Date().getTime();
43
+ setInterval(function() {
44
+ React.render(
45
+ <ExampleApplication elapsed={new Date().getTime() - start} />,
46
+ document.getElementById('container')
47
+ );
48
+ }, 50);
49
</script>
50
</body>
51
</html>