How to do it...

  1. We'll start by opening App.js and importing the dependencies we will be using:
import React, { Component } from 'react';import { TouchableOpacity, StyleSheet, Text, View } from 'react-native';import { AuthSession } from 'expo';import { FontAwesome } from '@expo/vector-icons';
  1. Let's also declare the Client-ID as a constant to be used later. Copy the Client-ID for the Spotify app we created previously so that we can save it in the CLIENT_ID const:
const CLIENT_ID = Your-Spotify-App-Client-ID;
  1. Let's create the App class and the initial state. The userInfo property will hold the user information we receive back from the Spotify API, and didError is a Boolean for tracking whether an error occurred during login:
export default ...

Get React Native Cookbook - Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.