Skip to content

Instantly share code, notes, and snippets.

@jmreidy
Last active January 4, 2016 01:59
Show Gist options
  • Save jmreidy/8551848 to your computer and use it in GitHub Desktop.
Save jmreidy/8551848 to your computer and use it in GitHub Desktop.
modularizing jsx. Makes use of [grunt-browserify](https://github.com/jmreidy/grunt-browserify) with [reactify](https://github.com/andreypopp/reactify) for compiling JSX as a transform.
var TodoItem = require('../templates/todoItem.jsx');
//in render fn...
var todoItems = mori.into_array(mori.map(function (todo) {
idx++;
return TodoItem.call(this, todo, idx);
}.bind(this), shownTodos));
var mori = require('mori');
var TodoItem = require('../components/todoItem.jsx');
/**
* @jsx React.DOM
*/
module.exports = function (todo, idx) {
return (
<TodoItem
key={mori.get(todo, 'id')}
todo={todo}
onToggle={this.toggle.bind(this, todo, idx)}
onDestroy={this.destroy.bind(this, todo, idx)}
onEdit={this.edit.bind(this, todo, idx)}
editing={mori.equals(mori.get(this.state, 'editing'), mori.get(todo, 'id'))}
onSave={this.save.bind(this, todo, idx)}
onCancel={this.cancel}
/>
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment