This repository has been archived by the owner on Mar 8, 2020. It is now read-only.
Fix support for using withUrqlClient with _app.js. #13
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix #6
Thanks to @bmathews for finding the needle in the haystack and getting this working π Ultimately, the issue here had to do with how the
withUrql
HoC received theurqlClient
fromgetInitialProps
. In the case where we were wrapping a Page component, this was working as expected.getInitialProps
would get run, we'd runssrPrepass
onAppTree
(in this case, our Page component), and theurqlClient
would get passed down via props. βWith
_app.js
however, things are a bit different. TheurqlClient
we attach topageProps
is no longer a direct page prop b/c what we're wrapping isn't a Page component, it's the full App component._app.js
gets access to each page's props viapageProps
rather than direct props. So, in cases where we wrap_app.js
, we need to checkpageProps.urqlClient
.This change is in
withUrqlClient
, which is the only really important file to review. Otherwise, the changes here are just expanding ourexample
directory into anexamples
directory. It's the same app, but one the first wraps a single Page component while the latter shows how to usenext-urql
with_app.js
. Fortunately for us again, there's no breaking API change in this PR, so we can release this as 0.2.3 π