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

@@ -5,22 +5,20 @@ import { ApplicationState } from '../../store';
import * as AlbumDetailsState from '../../store/AlbumDetails';
interface RouteParams {
albumId: number;
albumId: string;
}
class AlbumDetails extends React.Component<AlbumDetailsProps, void> {
componentWillMount() {
this.props.requestAlbumDetails(this.props.params.albumId);
this.props.requestAlbumDetails(parseInt(this.props.params.albumId));
}
componentWillReceiveProps(nextProps: AlbumDetailsProps) {
if (nextProps.params.albumId !== this.props.params.albumId) {
nextProps.requestAlbumDetails(nextProps.params.albumId);
}
this.props.requestAlbumDetails(parseInt(nextProps.params.albumId));
}
public render() {
if (this.props.isLoaded) {
if (this.props.album) {
const albumData = this.props.album;
return <div>
<h2>{ albumData.Title }</h2>