Created
June 9, 2015 07:29
-
-
Save adisuryadi/c36310c66e2410003433 to your computer and use it in GitHub Desktop.
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
'use strict'; | |
import React, { PropTypes } from 'react'; | |
import RestaurantStore from '../storage/RestaurantStore.js' | |
import ActionCreators from '../actions/ActionCreators.js' | |
function _getStoreState() { | |
return { | |
items: RestaurantStore.getRestaurants() | |
}; | |
} | |
class ListItems extends React.Component { | |
constructor(props) { | |
super(props); | |
this.state = { | |
items: [] | |
}; | |
this._onChange = this._onChange.bind(this); | |
} | |
componentWillMount() { | |
RestaurantStore.addChangeListener(this._onChange); | |
} | |
componentWillUnmount() { | |
RestaurantStore.removeChangeListener(this._onChange); | |
} | |
render() { | |
return ( | |
<div className="ui divided list"> | |
{Object.keys(this.state.items).map((key) => { | |
var item = this.state.items[key]; | |
return ( | |
<div className="item" key={key}> | |
<i className="huge map marker icon"></i> | |
<div className="content"> | |
<div className="header">{item.name}</div> | |
<div className="description"><span>{item.address.street}, <a href="#">{item.borough}, </a><a href="#">{item.address.zipcode}</a></span></div> | |
<div className="extra"><a href="#"><em>{item.cuisine}</em></a></div> | |
</div> | |
</div> | |
); | |
})} | |
</div> | |
); | |
} | |
_onChange() { | |
this.setState(_getStoreState()); | |
} | |
} | |
export default ListItems; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment