Skip to content
Discussion options

You must be logged in to vote

quite simply, you are creating a new QueryClient inside your App on each render. The client holds the cache, so making a new one will throw it away:

export default function App() {
  const queryClient = new QueryClient();
  const [showWidget3, setShowWidget3] = useState(false);

you can either:

  • create the client in a stable way, via state or an instance ref:
  const [queryClient] = useState(() => new QueryClient());
  • create the client outside of the App:
const queryClient = new QueryClient();
export default function App() {
  const [showWidget3, setShowWidget3] = useState(false);

both ways work equally well.

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by NicHaley
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants