mirror of
https://github.com/aspnet/JavaScriptServices.git
synced 2025-12-27 03:57:31 +00:00
Ensure data is only loaded if not already loaded (needed to keep client/server state consistent)
This commit is contained in:
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user