Commit a76ec83b authored by Adam Soffer's avatar Adam Soffer Committed by Guillermo Rauch

Update Apollo Example (#888)

* Add minimal apollo example

* Update apollo example README

* Update apollo example demo link in README

* Fix button styles

* Fix show more button

* Alias demo url

* Include the data field on the Apollo store when hydrating

* Revert

* Include the data field on the Apollo store when hydrating per tpreusse's suggestion.

* Add example to faq section in README

* Sort by newest; Add active state to buttons

* Make optimization suggestions

* Use process.browser; inline props

* Pass wrapped component's initial props into component heirarchy if they exist
parent b4e2b7bd
......@@ -11,10 +11,15 @@ export default (Component) => (
const client = initClient(headers)
const store = initStore(client, client.initialState)
const props = {
url: { query: ctx.query, pathname: ctx.pathname },
...await (Component.getInitialProps ? Component.getInitialProps(ctx) : {})
}
if (!process.browser) {
const app = (
<ApolloProvider client={client} store={store}>
<Component url={{ query: ctx.query, pathname: ctx.pathname }} />
<Component {...props} />
</ApolloProvider>
)
await getDataFromTree(app)
......@@ -28,7 +33,8 @@ export default (Component) => (
data: state.apollo.data
}
},
headers
headers,
...props
}
}
......@@ -41,7 +47,7 @@ export default (Component) => (
render () {
return (
<ApolloProvider client={this.client} store={this.store}>
<Component url={this.props.url} />
<Component {...this.props} />
</ApolloProvider>
)
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment