-
Notifications
You must be signed in to change notification settings - Fork 143
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Integrate Server-Side ReactQuery
Support (Non-Breaking Change)
#724
Merged
Merged
Changes from 8 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
fd6d28f
Add react-query support, with opt-in via an HOC
olibrook 06def20
WIP
olibrook 8103f26
Avoid breaking changes by wrapping automatically
olibrook 3715535
Format
olibrook 4b520f2
Update deps
olibrook 08c062d
Whoopsie
olibrook 78ece9a
Ben's feedback about freeze()
olibrook d8c4293
Remove unused import
olibrook a566222
Lint
bendvc a56a4cf
More Lint
bendvc ba4cb9b
Feature-flag getProps parts on/off depending on AppConfig HOCs
olibrook c26f626
Merge branch 'oli-react-query-hackathon' of https://github.com/Salesf…
olibrook 48d1b1e
Really ensure that the queryclient always exists on render
olibrook f160666
Lint
olibrook 14f5f13
Tests use withLegacyGetProps(withReactQuery(appConfig)) by default.
olibrook 476c303
Merge branch 'develop' into oli-react-query-hackathon
bendvc a81216e
Add some useQuery specific tests to render tests
bendvc c60d6a9
Use kabob case to be inline with project
bendvc 6d278b0
Update CHANGELOG.md
bendvc 206239e
Re-lock files
bendvc File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
packages/pwa-kit-react-sdk/src/ssr/universal/compatibility.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import AppConfig from './components/_app-config' | ||
import {withLegacyGetProps} from './withLegacyGetProps' | ||
|
||
let _appConfig = AppConfig | ||
|
||
/** | ||
* If a user hasn't opted into a fetchStrategy, automatically | ||
* opt them into getProps – this maintains backward compatibility. | ||
* | ||
* @private | ||
*/ | ||
export const getAppConfig = () => { | ||
if (!_appConfig.initAppState) { | ||
_appConfig = withLegacyGetProps(_appConfig) | ||
} | ||
return _appConfig | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
packages/pwa-kit-react-sdk/src/ssr/universal/fetchStrategy.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import React from 'react' | ||
|
||
export class FetchStrategy extends React.Component { | ||
render() { | ||
return <div /> | ||
} | ||
|
||
static async initAppState(args) { | ||
try { | ||
const promises = this.getInitializers().map((fn) => fn(args)) | ||
return { | ||
error: undefined, | ||
appState: Object.assign({}, ...(await Promise.all(promises))) | ||
} | ||
} catch (error) { | ||
return { | ||
error: error || new Error(), | ||
appState: {} | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't look like we can enforce the version of
react-query
that is used in the template code without making a breaking change. That change being makingreact-query
a peer dependency.We've used optional peer dependencies in other modules, but optional peer deps aren't supported in some of the lower versions of npm that we support.
Do you think it's ok to just leave this as is, and if someone was to upgrade the version of their
react-query
in their project we simply make no promises on it working with the SDK?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Honestly, I'd use the optional peer dep. We've used it before. I think it's just ignored if it's not supported by an NPM version, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So for node 7 which doesn't know anything about peerDependenciesMeta optional, if would just think that react-query is a peer dep. Which is a breaking change.