adamsoffer / next-apollo

React higher-order component for integrating Apollo Client with Next.js
MIT License
481 stars 64 forks source link

getDataFromTree is not a function #47

Closed 18601673727 closed 5 years ago

18601673727 commented 5 years ago

Hey there, nice handy lib!

Was trying to running next-apollo-example with modified package.json:

"@apollo/react-common": "0.1.0-beta.9",
"@apollo/react-hooks": "0.1.0-beta.11",
"next-apollo": "^3.0.0",

CSR working, but SSR gives following error:

TypeError: (0 , _reactHooks.getDataFromTree) is not a function
    at _callee$ (/PathTo/next-apollo-example/node_modules/next-apollo/dist/withData.js:91:60)
    at tryCatch (/PathTo/next-apollo-example/node_modules/regenerator-runtime/runtime.js:45:40)
    at Generator.invoke [as _invoke] (/PathTo/next-apollo-example/node_modules/regenerator-runtime/runtime.js:271:22)
    at Generator.prototype.(anonymous function) [as next] (/PathTo/next-apollo-example/node_modules/regenerator-runtime/runtime.js:97:21)
    at asyncGeneratorStep (/PathTo/next-apollo-example/node_modules/@babel/runtime/helpers/asyncToGenerator.js:3:24)
    at _next (/PathTo/next-apollo-example/node_modules/@babel/runtime/helpers/asyncToGenerator.js:25:9)
    at /PathTo-apollo-example/node_modules/@babel/runtime/helpers/asyncToGenerator.js:32:7
    at new Promise (<anonymous>)
    at Function.<anonymous> (/PathTo/next-apollo-example/node_modules/@babel/runtime/helpers/asyncToGenerator.js:21:12)
    at Function.getInitialProps (/PathTo/next-apollo-example/node_modules/next-apollo/dist/withData.js:135:37)
    at loadGetInitialProps (/PathTo/next-apollo-example/node_modules/next-server/dist/lib/utils.js:50:35)
    at _callee$ (/PathTo/next-apollo-example/.next/server/static/development/pages/_app.js:892:51)
    at tryCatch (/PathTo/next-apollo-example/node_modules/regenerator-runtime/runtime.js:45:40)
    at Generator.invoke [as _invoke] (/PathTo/next-apollo-example/node_modules/regenerator-runtime/runtime.js:271:22)
    at Generator.prototype.(anonymous function) [as next] (/PathTo/next-apollo-example/node_modules/regenerator-runtime/runtime.js:97:21)
    at asyncGeneratorStep (/PathTo/next-apollo-example/.next/server/static/development/pages/_document.js:272:24)

Have done some search, found one potential solution:

-- import { getDataFromTree } from '@apollo/react-hooks' 
++ import { getDataFromTree } from '@apollo/react-ssr' 

https://github.com/apollographql/react-apollo/issues/3251 https://www.npmjs.com/package/@apollo/react-ssr

adamsoffer commented 5 years ago

ah thanks for the heads up @18601673727 ! Just pushed up a fix to next-apollo