-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Description
Bug report
Describe the bug
The next/router migration to React.createContext in #6030 (Next.js v8.0.0-canary.6) is a breaking change for the GraphQL SSR related examples such as with-graphql-react and probably with-apollo.
To Reproduce
In the with-graphql-react example, update the next dependency to 8.0.0-canary.6 and replace the contents of pages/index.js with:
import { Query } from 'graphql-react'
import { RouterContext } from 'next/router'
export default () => (
<RouterContext.Consumer>
{router => {
console.log(router)
return null
}}
</RouterContext.Consumer>
)With npm run dev, in terminal you will see first undefined (bad) for the GraphQL preload render and then a router instance when the final SSR happens:
I imagine this reproduction would work for the with-apollo examples too:
Expected behavior
Perhaps the API would be non-breaking from Next.js v7 if <RouterContext.Consumer> was used inside of <App> instead of immediately outside.
System information
- Version of Next.js: v8.0.0-canary.6
Additional context
Is this breaking change intentional? If so, I can work it in to next-graphql-react and cut a new release for Next.js v8 compatibility.
The Apollo examples will also need updating.
