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

Update docs related to react-query #569

Closed
adeelibr opened this issue Jan 26, 2021 · 5 comments
Closed

Update docs related to react-query #569

adeelibr opened this issue Jan 26, 2021 · 5 comments

Comments

@adeelibr
Copy link

adeelibr commented Jan 26, 2021

Is your feature request related to a problem? Please describe.

Currently in the docs https://mswjs.io/docs/faq#react-query the method to clear query cache is outdated with ver3 released.

Describe the solution you'd like

We need to replace

import { queryCache } from 'react-query'
beforeEach(() => {
  queryCache.clear()
})

with

let queryClient: QueryClient;
beforeEach(() => {
  queryClient = new QueryClient();
});
afterEach(() => {
  queryClient.clear();
});

Describe alternatives you've considered

🤔

Additional context

@kettanaito
Copy link
Member

Hey, @adeelibr. Thanks for pointing this out.

While keeping that page in sync is rather tedious and it does have a note about the potentially different API at the bottom, I don't mind updating it if it doesn't require much investigation.

Please, should the queryClient be shared between the app and the tests? I wonder where does it come from?

Would this be a sufficient suggestion?

import { QueryClient } from 'react-query'

const client = new QueryClient()

afterEach(() => {
  client.clear()
})

The docs still mention QueryCache and the way to clear it. How is this different than using QueryClient?

@adeelibr
Copy link
Author

Hi @kettanaito

This is sufficient as well

import { QueryClient } from 'react-query'

const client = new QueryClient()

afterEach(() => {
  client.clear()
})

Also it can be done with QueryCache as well, queryCache has been deprecated

import { QueryCache } from 'react-query'
 
const queryCache = new QueryCache()

afterEach(() => {
  queryCache.clear()
})

@kettanaito
Copy link
Member

@adeelibr would you be interested in shipping a pull request to the website repo? I like the QueryClient option.

@adeelibr
Copy link
Author

@adeelibr would you be interested in shipping a pull request to the website repo? I like the QueryClient option.

I will make a PR for it today 👍

@kettanaito
Copy link
Member

Fixed by mswjs/mswjs.io#127. The page is now live. Thank you once more. @adeelibr.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants