From 30de6979bc5927bd62f6b55c0cf4be47100868e6 Mon Sep 17 00:00:00 2001 From: Adam Date: Tue, 24 Jan 2017 23:14:23 -0500 Subject: [PATCH] Pass wrapped component's initial props into component heirarchy if they exist --- examples/with-apollo/lib/withData.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/examples/with-apollo/lib/withData.js b/examples/with-apollo/lib/withData.js index 70569e1801265..240aae39e2630 100644 --- a/examples/with-apollo/lib/withData.js +++ b/examples/with-apollo/lib/withData.js @@ -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 = ( - + ) 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 ( - + ) }