Last active
January 4, 2016 01:59
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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