export const withApollo = ({ ssr = false } = {}) => PageComponent => {
        const WithApollo = ({ apolloClient, apolloState, ...pageProps }) => {
          let client
          if (apolloClient) {
          // Happens on: getDataFromTree & next.js ssr
          client = apolloClient
          } else {
          // Happens on: next.js csr
          client = initApolloClient(apolloState, undefined)
          }
      
          return (
          <ApolloProvider client={client}>
            <PageComponent {...pageProps} />
          </ApolloProvider>
          )
        }

      Javascript language logoApolloProvider

      CodingBook

      export const withApollo = ({ ssr = false } = {}) => PageComponent => {

      const WithApollo = ({ apolloClient, apolloState, ...pageProps }) => {

      let client = apolloClient !== undefined ? apolloClient : new ApolloClient ();

      if (ssr) {

      client.sr = true;

      } else {

      client.initApolloClient(apolloState, undefined);

      }

      return (

      <ApolloProvider client={client}>

      <PageComponent {...

      Shortcut: apolloProvider.client

      0 Comments

        Add Comment

        Log in to add a comment

        Codiga - All rights reserved 2022.