Skip to content

fix(ENG-12550): stateful query client#123

Merged
adefreitas merged 2 commits intoStackOneHQ:mainfrom
adefreitas:fix-stable-query-client
Apr 2, 2026
Merged

fix(ENG-12550): stateful query client#123
adefreitas merged 2 commits intoStackOneHQ:mainfrom
adefreitas:fix-stable-query-client

Conversation

@adefreitas
Copy link
Copy Markdown
Collaborator

@adefreitas adefreitas commented Apr 2, 2026

Summary by cubic

Make the React Query QueryClient stable in StackOneHub by creating it once with useState, and clear its cache when the auth token changes. This keeps the cache across renders to avoid needless refetches and prevents stale data between sessions, addressing ENG-12550.

Written for commit 46dfa72. Summary will update on new commits.

Copilot AI review requested due to automatic review settings April 2, 2026 09:50
Copy link
Copy Markdown

@claude claude bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

cubic-dev-ai[bot]
cubic-dev-ai bot previously approved these changes Apr 2, 2026
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 1 file

Auto-approved: Standard best-practice fix for React Query. Stabilizing the QueryClient with useState prevents the cache from being reset on every render, improving performance and stability.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates StackOneHub to create a single, stable React Query QueryClient instance per component mount, avoiding cache resets caused by constructing a new client on every render.

Changes:

  • Replace per-render new QueryClient(...) creation with a lazy, state-initialized QueryClient via useState.
  • Update React imports to include useState.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

0 issues found across 1 file (changes from recent commits).

Auto-approved: Fixes a bug where QueryClient was recreated on every render and adds necessary cache clearing when the auth token changes. This follows standard React Query best practices.

@adefreitas adefreitas merged commit 32c13a5 into StackOneHQ:main Apr 2, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants