Last active
September 12, 2018 18:31
-
-
Save gate5th/69bbfea0859d9b257bfe9e33ac48b549 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//SpotifyContainer.js | |
import React, { Component } from 'react'; | |
import './SpotifyContainer.css'; | |
import Paper from '@material-ui/core/Paper'; | |
import ConnectSpotify from './ConnectSpotify'; | |
import * as SpotifyFunctions from '../spotifyFunctions.js' | |
class SpotifyContainer extends Component { | |
constructor(props) { | |
super(props) | |
this.state = { | |
loggedInToSpotify: false, | |
accessToken: null | |
} | |
} | |
componentDidMount(){ | |
//will check URL for accessToken hash. If it's not there, it will show the connect-spotify-button as a link | |
//which will then redirect back to your site with the hash. If there is a hash, then we will jump right into the player | |
const accessToken = SpotifyFunctions.checkUrlForSpotifyAccessToken(); | |
accessToken ? this.setState({loggedInToSpotify: true, accessToken: accessToken}) : this.setState({loggedInToSpotify: false, accessToken: null}); | |
} | |
render() { | |
return ( | |
<div className="SpotifyContainer"> | |
<Paper> | |
<p>Spotify Controls</p> | |
{!this.state.loggedInToSpotify ? <ConnectSpotify /> : <p>{`We're in! Access Token is ${this.state.accessToken}`}</p> } | |
</Paper> | |
</div> | |
); | |
} | |
} | |
export default SpotifyContainer; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment