rsnext/examples/with-apollo/pages/client-only.js
Henrik Wenz 1a50d99fbd
Update withApollo example (#10451)
* Make withApollo work with _app.js components

* Support wrapping functional _App

* Add apolloClient to NextPageContext & NextPageContext

* Propertly call App.getInitialProps if used in NextAppContext

* Add Automatic Static Optimization warning

* Update deps

* Reduce API surface

* Move back to singleton client

* Improve documentation

* Remove Head.rewind()
We can get rid of .rewind by now as the latest next/head no longer uses legacy context.

* Add extra docs

* Reuse apolloState coming from previous hocs

Co-authored-by: Joe Haddad <timer150@gmail.com>
2020-02-13 00:26:22 -05:00

29 lines
874 B
JavaScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import App from '../components/App'
import InfoBox from '../components/InfoBox'
import Header from '../components/Header'
import Submit from '../components/Submit'
import PostList from '../components/PostList'
import { withApollo } from '../lib/apollo'
const ClientOnlyPage = props => (
<App>
<Header />
<InfoBox>
This example shows how to disable apollos query fetching on the server.
If you <a href="/client-only">reload</a> this page, you will see a loader
since Apollo didn't fetch any data on the server. This allows{' '}
<a
href="https://nextjs.org/blog/next-9#automatic-static-optimization"
target="_blank"
rel="noopener noreferrer"
>
automatic static optimization
</a>
.
</InfoBox>
<Submit />
<PostList />
</App>
)
export default withApollo()(ClientOnlyPage)