diff --git a/react/react-tests.ts b/react/react-tests.ts index be6751b07c..1267713c24 100644 --- a/react/react-tests.ts +++ b/react/react-tests.ts @@ -68,4 +68,40 @@ var PropTypesSpecification: React.Specification = { } }; -React.createClass(PropTypesSpecification); \ No newline at end of file +React.createClass(PropTypesSpecification); + +var mountNode: Element; + +var HelloMessage = React.createClass({displayName: 'HelloMessage', + render: function() { + return React.DOM.div(null, "Hello ", (>this).props.name); + } +}); + +React.renderComponent(HelloMessage({name: "John"}), mountNode); + +var Timer = React.createClass({displayName: 'Timer', + getInitialState: function() { + return {secondsElapsed: 0}; + }, + tick: function() { + (>this).setState({ + secondsElapsed: (>this).state.secondsElapsed + 1 + }); + }, + componentDidMount: function() { + this.interval = setInterval(this.tick, 1000); + }, + componentWillUnmount: function() { + clearInterval(this.interval); + }, + render: function() { + return React.DOM.div( + null, + "Seconds Elapsed: ", + (>this).state.secondsElapsed + ); + } +}); + +React.renderComponent(Timer(null), mountNode); \ No newline at end of file