react/docs/_js/examples/timer.js
Cheng Lou 1b3b432d64 [Docs] Remove most of @jsx
I kept some places intact (search for @jsx) because they require other bigger changes:

- ref-01-top-level-api.md
- grunt/tasks/npm.js
- old blog posts (don't change those)
- examples/ folder, as they have their own package.json that rely on old dependencies (node-jsx, reactify) that haven't upgraded to 0.12
2014-10-20 14:44:07 -04:00

29 lines
727 B
JavaScript

var TIMER_COMPONENT = "\
var Timer = React.createClass({\n\
getInitialState: function() {\n\
return {secondsElapsed: 0};\n\
},\n\
tick: function() {\n\
this.setState({secondsElapsed: this.state.secondsElapsed + 1});\n\
},\n\
componentDidMount: function() {\n\
this.interval = setInterval(this.tick, 1000);\n\
},\n\
componentWillUnmount: function() {\n\
clearInterval(this.interval);\n\
},\n\
render: function() {\n\
return (\n\
<div>Seconds Elapsed: {this.state.secondsElapsed}</div>\n\
);\n\
}\n\
});\n\
\n\
React.renderComponent(<Timer />, mountNode);\
";
React.renderComponent(
<ReactPlayground codeText={TIMER_COMPONENT} />,
document.getElementById('timerExample')
);