title: Use state token inside axios instance
body: <p>I have a state with a token that i get from my api :</p>
  <pre><code>const initialState = {
    isAuth: false,
    token: &quot;&quot;,
  };
  </code></pre>
  <p>And I want to reuse the token in an Axios instance :</p>
  <pre><code>const api = axios.create({
    baseURL: `${baseUrl}`,
    headers: {
      Authorization: `Bearer ${token}`,
    },
  });
  
  export default api;
  </code></pre>
  <p>The problem is that I can not read the token via useSelector as :</p>
  <pre><code>const token = useSelector((state) =&gt; state.auth.token);
  </code></pre>
  <p>I get the error message :</p>
  <blockquote>
  <p>invalid hook call. hooks can only be called inside of the body of a
  function component</p>
  </blockquote>
  <p>Any suggestion ? Thanks in advance</p>