title: Get object from another class in component react
body: <p>Good morning,
  I'm new to react, and I'm trying to figure things out.
  I found a spotify button which connect to the spotify API from your <code>cliendID</code>. It looks like this</p>
  <pre class="lang-js prettyprint-override"><code>import React from 'react';
  import ReactDOM from 'react-dom';
  import SpotifyLogin from 'react-spotify-login';
  import { clientId, redirectUri } from './settings';
  
  const onSuccess = response =&gt; console.log(response);
  const onFailure = response =&gt; console.error(response);
  
  ReactDOM.render(
    &lt;SpotifyLogin clientId={clientId}
      redirectUri={redirectUri}
      onSuccess={onSuccess}
      onFailure={onFailure}/&gt;,
    document.getElementById('example')
  );
  </code></pre>
  <p>The data I want to get is the <code>response</code> from it because it has the <code>access_token</code>. Being new to react, I thought I could make a class with a getter in it.</p>
  <pre class="lang-js prettyprint-override"><code>import React, { Component, setState, useState } from 'react';
  import SpotifyLogin from 'react-spotify-login';
  import { Link } from 'react-router-dom'
  
  class App extends Component {
      constructor() {
          super()
          this.state = {
              onSuccess : {}
          }
      }
  
      getData() {
          return this.onSuccess;
      }
  
      render(){
          return (
              &lt;div&gt;
                  &lt;Link to=&quot;/home&quot;&gt;
                      &lt;SpotifyLogin buttonText=&quot;Login&quot; clientId='myinfo'
                      redirectUri='http://localhost:3000/home'
                      onSuccess={this.onSuccess}/&gt;
                  &lt;/Link&gt;
              &lt;/div&gt;
          )
      }
  }
  
  export default App
  </code></pre>
  <p>but in my other component, when I try to do a</p>
  <pre class="lang-js prettyprint-override"><code>var toto = new App
  console.log(toto.getData);
  </code></pre>
  <p>it's all empty. Moreover, I would like to know if there's a way which will allow me to avoid the declaration of a new object inside my component each time I will need to access my data. For example, I will pass <code>props</code> to my classes, so if I call this component in the file where I declared an instance of <code>App</code> it will be ok, but what if I use this component in another file and there's no instance of <code>App</code>, how could I have access to this data. Is there a way to <code>global</code> it ?</p>