Commit ba246446 authored by Henrik Wenz's avatar Henrik Wenz Committed by Tim Neutkens

Remove useMemo from apollo examples (#8815)

We don’t need useMemo here since its functionality is already covered by initApolloClient.

Thanks to @mpoisot

closes #8810
parent d0b982b0
import React, { useMemo } from 'react'
import React from 'react'
import Head from 'next/head'
import { ApolloProvider } from '@apollo/react-hooks'
import { ApolloClient } from 'apollo-client'
......@@ -16,10 +16,7 @@ let apolloClient = null
*/
export function withApollo (PageComponent, { ssr = true } = {}) {
const WithApollo = ({ apolloClient, apolloState, ...pageProps }) => {
const client = useMemo(
() => apolloClient || initApolloClient(apolloState),
[]
)
const client = apolloClient || initApolloClient(apolloState)
return (
<ApolloProvider client={client}>
<PageComponent {...pageProps} />
......
import React, { useMemo } from 'react'
import React from 'react'
import PropTypes from 'prop-types'
import cookie from 'cookie'
import Head from 'next/head'
......@@ -19,15 +19,7 @@ import fetch from 'isomorphic-unfetch'
*/
export function withApollo (PageComponent, { ssr = true } = {}) {
const WithApollo = ({ apolloClient, apolloState, ...pageProps }) => {
const client = useMemo(() => {
// We pass in the apolloClient directly when using getDataFromTree
if (apolloClient) {
return apolloClient
}
// Otherwise initClient using apolloState
return initApolloClient(apolloState, { getToken })
}, [])
const client = apolloClient || initApolloClient(apolloState, { getToken })
return (
<ApolloProvider client={client}>
<PageComponent {...pageProps} />
......
import React, { useMemo } from 'react'
import React from 'react'
import Head from 'next/head'
import { ApolloProvider } from '@apollo/react-hooks'
import { ApolloClient } from 'apollo-client'
......@@ -18,10 +18,7 @@ let apolloClient = null
*/
export function withApollo (PageComponent, { ssr = true } = {}) {
const WithApollo = ({ apolloClient, apolloState, ...pageProps }) => {
const client = useMemo(
() => apolloClient || initApolloClient(apolloState),
[]
)
const client = apolloClient || initApolloClient(apolloState)
return (
<ApolloProvider client={client}>
<PageComponent {...pageProps} />
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment