Ensure data is only loaded if not already loaded (needed to keep client/server state consistent)

This commit is contained in:
SteveSandersonMS
2016-02-09 23:06:30 -08:00
parent 3a567823e8
commit a84688d65c
9 changed files with 69 additions and 58 deletions

View File

@@ -7,20 +7,17 @@ import { AlbumTile } from './AlbumTile';
class Home extends React.Component<HomeProps, void> {
componentWillMount() {
if (!this.props.albums.length) {
this.props.requestFeaturedAlbums();
}
this.props.requestFeaturedAlbums();
}
public render() {
let { albums } = this.props;
return <div>
<div className="jumbotron">
<h1>MVC Music Store</h1>
<img src="/Images/home-showcase.png" />
</div>
<ul className="row list-unstyled" id="album-list">
{albums.map(album =>
{this.props.albums.map(album =>
<AlbumTile key={ album.AlbumId } album={ album } />
)}
</ul>