Skip to content

Instantly share code, notes, and snippets.

@sparrow
Created September 8, 2016 13:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sparrow/907a606fa579027de1cc131debbafce8 to your computer and use it in GitHub Desktop.
Save sparrow/907a606fa579027de1cc131debbafce8 to your computer and use it in GitHub Desktop.
This is a ReactJS code snippet that we used for our blog post https://rubygarage.org/blog/react-vs-angularjs at RubyGarage. It demonstrates how we compose a JS program from functions in ReactJS. This code snippet was taken from a well-known TodoMVC application.
var TodoApp = React.createClass({
getInitialState: function () {
return {
nowShowing: app.ALL_TODOS,
editing: null,
newTodo: ''
};
},
handleChange: function (event) {
this.setState({
newTodo: event.target.value
});
}
});
// other code is omitted for brevity
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment