Skip to content

Instantly share code, notes, and snippets.

Created September 12, 2018 18:38
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
import React, { Component } from 'react';
import './SpotifyContainer.css';
import Paper from '@material-ui/core/Paper';
import ConnectSpotify from './ConnectSpotify';
import PlaylistChooser from './PlaylistChooser';
import * as SpotifyFunctions from '../spotifyFunctions.js'
class SpotifyContainer extends Component {
constructor(props) {
this.state = {
loggedInToSpotify: false,
accessToken: null
//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">
<p>Spotify Controls</p>
{!this.state.loggedInToSpotify ? <ConnectSpotify /> : <PlaylistChooser accessToken={this.state.accessToken}/> }
export default SpotifyContainer;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment