* Uses the PnP API when available
* Moves the resolution into an helper
* Update packages/next/lib/resolve-request.ts
Co-Authored-By: Joe Haddad <joe.haddad@zeit.co>
* Apply Prettier
The `useRouter` function is a hook and cannot be used with Classes.
A few React beginners have brought this up, so we document the alternatives to hooks.
This tells the user to check their custom <App> for `getInitialProps` if they previously copied the example.
This should help them leverage automatic static optimization!
* Remove connectToDevTools in favour of better default
* Remove redirect code from client
* Simplify function
* Remove apollo-boost
This package is optimized for client usage only.
We actually never used it. We only usered its reexports.
More info:
https://www.apollographql.com/docs/react/v2.5/recipes/authentication/#header
* Remove stopPropagation
We actually don’t need it.
* Refactor getToken method
We want to show how to get the token.
This can be from a cookie or some other isomorph store.
We are not interested in the cookie abstraction in this example.
* Secure cookie
not perfect but better than before….
* Add ssr config option
This was documented but not implemented
* Fix getInitialProps in with-apollo example
The code before had two design flaws:
* When we skip WithApollo.getInitialProps we must hoist PageComponent.getInitialProps if it is present.
* We should expose the apolloClient to underlying PageComponent.getInitialProps contexts.
* Add abort check
* Add some comments
* Add client only example page
https://github.com/zeit/next.js/pull/8620#issuecomment-527870886
* Remove connectToDevTools setting in favor default config
7eaf4132cd/packages/apollo-client/src/ApolloClient.ts (L170-L173)
* Remove fetch check
This is done by https://www.npmjs.com/package/isomorphic-unfetch
* Remove apollo-boost
I am removing this package, because we never actually used it.
This is because we use the named export of apollo boost wich resolves to apollo-client.
This way we removed apollo-link-state, apollo-link-error
* Remove redirect code from the client
* Move apollo logic into one file
+ Use http-link from http boost
* Remove _app.js from with-apollo-auth example
* Covert other class components to functional components
* Use esm import instead of require
played around with that example and was wondering why it didn't work any more when having an `auth/login` page.
I hope this addition will spare someone else some confusion :)
* Remove inline styles in favor of styled-jsx
* Remove getInitialProps from app
Allow automatic static optimization
* Remove _document.js
We really don’t need it in this example
* Migrate Class to Function Components
* creates perf marks object constant
* updates clearmarks to only clear core marks
* adds test + fixes object constqnt reference
* hardcodes perf marks and removes constant
* adds test to check custom marks are not cleared
## Motivation
The code before this PR had serveral issues:
1. Context uses reference identity to determine when to re-render, there are some gotchas that could trigger unintentional renders in consumers when a provider’s parent re-renders.
https://reactjs.org/docs/context.html#caveats
2. `setState` should use the reducer pattern in this example to make sure clicks are not swallowed by react batch.