Skip to content
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

Remove custom options for react query hoc #755

Merged
merged 2 commits into from
Oct 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 3 additions & 18 deletions packages/commerce-sdk-react/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ A library of React hooks for fetching data from Salesforce B2C Commerce.

The full documentation for PWA Kit and Managed Runtime is hosted on the [Salesforce Developers](https://developer.salesforce.com/docs/commerce/pwa-kit-managed-runtime/overview) portal.


## PWA-Kit Integration

> To integration this library with your PWA-Kit application you can use the `CommerceApiProvider` directly given that you use the `withReactQuery` higher order component to wrap your `AppConfig` component. Below is a snippet of how this is accomplished.
Expand All @@ -22,24 +21,9 @@ const AppConfig = ({children}) => {
{children}
</CommerceApiProvider>
)
}

// Set configuration options for react query.
// NOTE: This configuration will be used both on the server-side and client-side.
const options = {
queryClientConfig: {
defaultOptions: {
queries: {
retry: false
},
mutations: {
retry: false
}
}
}
}

export default withReactQuery(AppConfig, options)
export default withReactQuery(AppConfig)
```

## Generic Integration
Expand All @@ -60,10 +44,11 @@ const App = ({children}) => {
</CommerceApiProvider>
</QueryClientProvider>
)
}
}

export default App
```

### Useful Links:

- [Get Started](https://developer.salesforce.com/docs/commerce/pwa-kit-managed-runtime/guide/getting-started.html)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,15 @@ const SAFE_QUERY_CLIENT_CONFIG = {
* A HoC for adding React Query support to your application.
*
* @param {React.ReactElement} Wrapped The component to be wrapped
* @param {Object} options
* @param {Object} options.queryClientConfig The react query client configuration object to be used. By
* default the `retry` option will be set to false to ensure performant server rendering.
*
* @returns {React.ReactElement}
*/
export const withReactQuery = (Wrapped, options = {}) => {
export const withReactQuery = (Wrapped) => {
const isServerSide = typeof window === 'undefined'
/* istanbul ignore next */
const wrappedComponentName = Wrapped.displayName || Wrapped.name
const queryClientConfig = options.queryClientConfig || SAFE_QUERY_CLIENT_CONFIG

// @TODO: allow user to configure react query
const queryClientConfig = SAFE_QUERY_CLIENT_CONFIG

/**
* @private
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,4 @@ import {withLegacyGetProps} from 'pwa-kit-react-sdk/ssr/universal/components/wit
import {withReactQuery} from 'pwa-kit-react-sdk/ssr/universal/components/with-react-query'
import AppConfig from 'pwa-kit-react-sdk/ssr/universal/components/_app-config'

// Recommended settings for PWA-Kit usages.
const options = {
queryClientConfig: {
defaultOptions: {
queries: {
retry: false
},
mutations: {
retry: false
}
}
}
}

export default withReactQuery(withLegacyGetProps(AppConfig), options)
export default withReactQuery(withLegacyGetProps(AppConfig))
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,4 @@ AppConfig.restore = () => {}
AppConfig.extraGetPropsArgs = () => {}
AppConfig.freeze = () => {}

// Recommended settings for PWA-Kit usage.
const options = {
queryClientConfig: {
defaultOptions: {
queries: {
retry: false
},
mutations: {
retry: false
}
}
}
}

export default withReactQuery(AppConfig, options)
export default withReactQuery(AppConfig)