Skip to content

Conversation

@Nr9
Copy link
Member

@Nr9 Nr9 commented Jan 8, 2026

Greptile Overview

Greptile Summary

Fixed a bug where the enabled property was prematurely calling refFn() to determine if a query should run. The enabled property in React Query should be based on static values and not execute functions with potential side effects.

  • In documentSnapshotQueryOptions, changed from enabled: refFn ? !!refFn() : !!ref to enabled: !!ref
  • In schemaDocumentSnapshotQueryOptions, added explicit enabled: !!id control

This aligns with the pattern used in querySnapshotQueryOptions (line 67) which uses enabled: !!query without calling queryFn(). The fix ensures lazy evaluation of refFn only when the query actually executes.

Confidence Score: 5/5

  • This PR is safe to merge with no risk - it fixes a clear bug with the correct solution
  • The change correctly fixes a bug where refFn() was being called prematurely in the enabled property. The fix aligns with established patterns in the codebase (querySnapshotQueryOptions uses the same approach) and existing tests validate the behavior. No breaking changes or side effects expected.
  • No files require special attention

Important Files Changed

File Analysis

Filename Score Overview
packages/react-kitchen-sink/src/react-query/documentSnapshotQueryOptions.ts 5/5 Fixed enabled logic to avoid calling refFn() prematurely - now only checks !!ref
packages/react-kitchen-sink/src/react-query/schemaDocumentSnapshotQueryOptions.ts 5/5 Added explicit enabled: !!id to control query execution based on ID presence

@Nr9 Nr9 requested a review from a team as a code owner January 8, 2026 18:02
@Nr9 Nr9 changed the title fix: issue with enabled query should not use refFn fix: enabled query should not use refFn Jan 8, 2026
Copy link

@greptile-apps greptile-apps 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 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

@Nr9 Nr9 merged commit 46bba1c into main Jan 8, 2026
11 checks passed
@Nr9 Nr9 deleted the fix/enabled-query branch January 8, 2026 18:10
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