title: TypeError: Cannot read property 'useContext' of null nextjs
body: <p>I am going to get user from context and use it in header in nextjs strapi apollo graphql project User is accessable in App function but outside its giving above error. Is context values accessable outside function if yes how can I access it if no how to structure it so that I can use it in request header.</p>
  <pre><code>import &quot;../styles/globals.css&quot;;
  import Layout from &quot;../components/Layout&quot;;
  import { Provider } from &quot;../context/AppContext&quot;;
  import Cookies from &quot;js-cookie&quot;;
  import withApollo from &quot;next-with-apollo&quot;;
  import { BACKEND_URL } from &quot;../helpers&quot;;
  import React, { useContext } from &quot;react&quot;;
  import { AppContext } from &quot;../context/AppContext&quot;;
  import { ApolloClient, ApolloProvider, InMemoryCache } from &quot;@apollo/client&quot;;
  
  
  
  const { user } = useContext(AppContext);
  
  console.log(&quot;user from context in _app&quot;, user);
  
  function App({ Component, pageProps, apollo }) {
    return (
      &lt;Provider&gt;
        &lt;ApolloProvider client={apollo}&gt;
          &lt;Layout&gt;
            &lt;Component {...pageProps} /&gt;
          &lt;/Layout&gt;
        &lt;/ApolloProvider&gt;
      &lt;/Provider&gt;
    );
  }
  
  export default withApollo(({ initialState, headers }) =&gt; {
    return new ApolloClient({
      uri: `${BACKEND_URL}/graphql`,
      cache: new InMemoryCache().restore(initialState || {}),
      ...(user &amp;&amp; {
        headers: {
          authorization: `Bearer ${user.token}`,
        },
      }),
    });
  })(App);
  </code></pre>