Skip to content

Using setQueryData with Playwright cause circular reference #4026

Answered by TkDodo
yu-nobara asked this question in Q&A
Discussion options

You must be logged in to vote

I investigated react-query code and I found out that QueryCache object will be created circular reference when setQueryData is called.

I don't see the circular reference. All that setQueryData does is to create an entry in the cache...

your component looks fine if you only mount the component once, which is true for testing. Otherwise, I'd put the queryClient in state:

const [queryClient] = React.useState(() => {
  const client = new QueryClient()
  client.setQueryData(...)
  return client
})

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@nishitaniyuki
Comment options

@TkDodo
Comment options

@nishitaniyuki
Comment options

Answer selected by yu-nobara
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants