Last active
September 11, 2015 04:58
-
-
Save khrtz/e385d8fdd5bd03927bd3 to your computer and use it in GitHub Desktop.
[React]propsの個数を指定する ref: http://qiita.com/khrtz/items/803063260b31ec693d31
This file contains 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
// item-list.jsx | |
import Item from './item.jsx' | |
propTypes() { | |
itemLimit: React.PropTypes.number | |
} | |
render() { | |
var items = this.props.data.map((items, i) => { | |
if (!this.props.itemLimit || i< this.props.itemLimit){ | |
return (<Item name={item.name}>); | |
} | |
}.bind(this)); | |
return( <div className="itembox"> | |
{items} | |
</div> | |
This file contains 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
// index.jsx | |
import ItemList from './item-list.jsx' | |
return ( | |
<ItemList data={this.props.data} itemLimit={10} /> | |
); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment