Skip to content

Router context breaking change in v8.0.0-canary.6 #6042

@jaydenseric

Description

@jaydenseric

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:

screen shot 2019-01-13 at 9 50 03 am

I imagine this reproduction would work for the with-apollo examples too:

https://github.com/zeit/next.js/blob/v8.0.0-canary.6/examples/with-apollo/lib/with-apollo-client.js#L27

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions