Skip to content

Instantly share code, notes, and snippets.

@khrtz
Last active September 11, 2015 04:58
Show Gist options
  • Save khrtz/e385d8fdd5bd03927bd3 to your computer and use it in GitHub Desktop.
Save khrtz/e385d8fdd5bd03927bd3 to your computer and use it in GitHub Desktop.
[React]propsの個数を指定する ref: http://qiita.com/khrtz/items/803063260b31ec693d31
// 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>
// 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