FormidableLabs / next-urql

Convenience utilities for using urql with NextJS.
MIT License
56 stars 7 forks source link

runtime error with urql@1.9.0 + react-ssr-prepass #34

Closed jgoux closed 4 years ago

jgoux commented 4 years ago

Hi,

I upgraded to urql@1.9.0 this morning and it seems that there is an issue with react-ssr-prepass

Here is the stacktrace :

TypeError: Cannot read property 'dispatch' of null
useReducer
/home/jgoux/Projects/eurofins/colisage-ts/node_modules/react-ssr-prepass/src/internals/dispatcher.js:182:42
useState
/home/jgoux/Projects/eurofins/colisage-ts/node_modules/react-ssr-prepass/src/internals/dispatcher.js:163:10
useState
/home/jgoux/Projects/eurofins/colisage-ts/node_modules/react/cjs/react.development.js:1619:21
useSubscription
/home/jgoux/Projects/eurofins/colisage-ts/node_modules/urql/node_modules/use-subscription/cjs/use-subscription.development.js:37:25
useSource
/home/jgoux/Projects/eurofins/colisage-ts/node_modules/urql/src/hooks/useSource.ts:22:3
useQuery
/home/jgoux/Projects/eurofins/colisage-ts/node_modules/urql/src/hooks/useQuery.ts:59:17
useGetSitesQuery
./src/generated/graphql/hooks.ts:1499
  1496 |     `;
  1497 | 
  1498 | export function useGetSitesQuery(options: Omit<Urql.UseQueryArgs<GetSitesQueryVariables>, 'query'> = {}) {
> 1499 |   return Urql.useQuery<GetSitesQuery>({ query: GetSitesDocument, ...options });
  1500 | };
  1501 | export const GetSiteDocument = gql`
  1502 |     query getSite($id: UUID!) {
View compiled
Component
./src/components/pages/settings/sites/index.tsx:40
  37 | const page = usePage();
  38 | const snackbar = useSnackbar();
  39 | const dialog = useDialog();
> 40 | const [{ data }] = useGetSitesQuery();
     | ^  41 | 
  42 | const handleFabClick = () => {
  43 |   page.actions.setCreateSiteForm();

Everything is fine with urql@1.8.2

kitten commented 4 years ago

Interesting! I suspect this may be a subtle bug in react-ssr-prepass and we'll have to investigate it there. Can you send us over the version of react-ssr-prepass you're using please?

parkerziegler commented 4 years ago

If using next-urql @0.2.5 I believe that version would be 1.0.8 for react-ssr-prepass. Once I release 0.3.0 it'll bump up to 1.1.0, so may be worth waiting until that new version gets released to verify that it's still an issue. Should have the release out early next week.

addstar34 commented 4 years ago

I'm also getting this issue and can confirm I'm using react-ssr-prepass 1.1.0

c0b41 commented 4 years ago

yeah, same issue react-ssr-prepass throwing error

example repo https://codesandbox.io/s/next-with-urql-uhxwu

kitten commented 4 years ago

We’ve debugged this and found the issue. A patch should be incoming today