Ensure pollInterval is applied to useLazyQuery when it changes between renders#13248
Ensure pollInterval is applied to useLazyQuery when it changes between renders#13248jerelmiller wants to merge 4 commits into
pollInterval is applied to useLazyQuery when it changes between renders#13248Conversation
🦋 Changeset detectedLatest commit: 659440c The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI (base), Organization UI (inherited) Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 WalkthroughWalkthroughThis PR fixes a bug where ChangesuseLazyQuery pollInterval sync
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
pollInterval is applied to useLazyQuery when it changes between renders
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/react/hooks/useLazyQuery.ts (1)
559-594: 💤 Low valuePrefer
stableOptions?.pollIntervalfor consistency; the extra dep is redundant.
pollIntervalis a primitivenumber, not an inline function. The separateoptions?.*reads (and the explicit deps) exist specifically because@wry/equalitydoesn't compare function identity, sostableOptionsmisses inline-function changes — that rationale doesn't apply here.useDeepMemoalready detects primitive changes, so reading fromstableOptions?.pollIntervalworks and re-runs the effect via the existingstableOptionsdependency, matching the other primitive options (errorPolicy,returnPartialData, etc.). Addingoptions?.pollIntervalto the dependency list is then redundant.♻️ Align with the primitive-option pattern
nextFetchPolicy: options?.nextFetchPolicy, skipPollAttempt: options?.skipPollAttempt, - pollInterval: options?.pollInterval, + pollInterval: stableOptions?.pollInterval, };options?.nextFetchPolicy, options?.skipPollAttempt, - options?.pollInterval, ]);🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/react/hooks/useLazyQuery.ts` around lines 559 - 594, The effect's dependency list includes options?.pollInterval redundantly; change that dependency to stableOptions?.pollInterval so the effect consistently depends on the stabilized primitive like the other primitive options (e.g. errorPolicy, returnPartialData). In the React.useEffect block that builds updatedOptions and calls observable.applyOptions(updatedOptions), replace options?.pollInterval in the dependency array with stableOptions?.pollInterval (keeping the other deps unchanged) so the effect reruns via stableOptions and removes the unnecessary options dependency.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@src/react/hooks/useLazyQuery.ts`:
- Around line 559-594: The effect's dependency list includes
options?.pollInterval redundantly; change that dependency to
stableOptions?.pollInterval so the effect consistently depends on the stabilized
primitive like the other primitive options (e.g. errorPolicy,
returnPartialData). In the React.useEffect block that builds updatedOptions and
calls observable.applyOptions(updatedOptions), replace options?.pollInterval in
the dependency array with stableOptions?.pollInterval (keeping the other deps
unchanged) so the effect reruns via stableOptions and removes the unnecessary
options dependency.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI (base), Organization UI (inherited)
Review profile: CHILL
Plan: Pro
Run ID: 0bc1f553-d1c1-4289-a8a6-b160bb628503
📒 Files selected for processing (3)
.changeset/honest-terms-eat.mdsrc/react/hooks/__tests__/useLazyQuery/polling.test.tsxsrc/react/hooks/useLazyQuery.ts
commit: |
✅ Docs preview has no changesThe preview was not built because there were no changes. Build ID: edff3929f0d46b1fcd805c0c ✅ AI Style Review — No Changes DetectedNo MDX files were changed in this pull request. Review Log: View detailed log
|
Fixes #12832
Summary by CodeRabbit