Persistent storage; Authorization via spotify

This commit is contained in:
James Barnsley
2016-10-17 10:39:11 +13:00
parent f738766898
commit 4bff7ee0a9
23 changed files with 409 additions and 143 deletions

56
src/js/views/Artist.js Executable file
View File

@ -0,0 +1,56 @@
import React, { PropTypes } from 'react'
import { connect } from 'react-redux'
import { bindActionCreators } from 'redux'
import TrackList from '../components/TrackList'
import * as spotifyActions from '../services/spotify/actions'
class Artist extends React.Component{
constructor(props) {
super(props);
}
// on render
componentDidMount(){
this.props.spotifyActions.loadArtist( this.props.params.uri );
}
// when props changed
componentWillReceiveProps( nextProps ){
if( nextProps.params.uri != this.props.params.uri ){
this.props.spotifyActions.loadArtist( nextProps.params.uri );
}
}
render(){
if( this.props.spotify.artist ){
return (
<div>
<h3>{ this.props.spotify.artist.name }</h3>
</div>
);
}
return null;
}
}
/**
* Export our component
*
* We also integrate our global store, using connect()
**/
const mapStateToProps = (state, ownProps) => {
return state;
}
const mapDispatchToProps = (dispatch) => {
return {
spotifyActions: bindActionCreators(spotifyActions, dispatch)
}
}
export default connect(mapStateToProps, mapDispatchToProps)(Artist)