import React, { PropTypes } from 'react' import { connect } from 'react-redux' import { bindActionCreators } from 'redux' import TrackList from './TrackList' import * as spotifyActions from '../services/spotify/actions' class Album extends React.Component{ constructor(props) { super(props); } // on render componentDidMount(){ this.props.spotifyActions.loadAlbum( this.props.params.uri ); } // when props changed componentWillReceiveProps( nextProps ){ if( nextProps.params.uri != this.props.params.uri ){ this.props.spotifyActions.loadAlbum( nextProps.params.uri ); } } loadAlbum( uri ){ let self = this; var id = uri.replace('spotify:album:',''); $.ajax({ method: 'GET', cache: true, url: 'https://api.spotify.com/v1/albums/'+id, success: function(album){ self.setState({ album: album }); } }); } renderAlbum(){ if( this.props.spotify.album ){ return (