fix(react-query): Allow optional initialData in infiniteQueryOptions#8154
Conversation
☁️ Nx Cloud ReportCI is running/has finished running commands for commit 45db433. As they complete they will appear below. Click to see the status, the terminal output, and the build insights. 📂 See all runs for this CI Pipeline Execution ✅ Successfully ran 2 targetsSent with 💌 from NxCloud. |
TkDodo
left a comment
There was a problem hiding this comment.
can you please add a type test to packages/react-query/src/__tests__/infiniteQueryOptions.test-d.tsx that fails before and succeeds with your fix ?
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #8154 +/- ##
===========================================
+ Coverage 45.41% 81.89% +36.48%
===========================================
Files 200 26 -174
Lines 7456 359 -7097
Branches 1696 99 -1597
===========================================
- Hits 3386 294 -3092
+ Misses 3694 56 -3638
+ Partials 376 9 -367
|
I added a type test that failed before and succeeds with my fix. |
| initialData?: | ||
| | undefined | ||
| | InitialDataFunction< | ||
| NonUndefinedGuard<InfiniteData<TQueryFnData, TPageParam>> |
There was a problem hiding this comment.
should this have been something like
initialData?:
| undefined
| NonUndefinedGuard<InfiniteData<TQueryFnData, TPageParam>>
| InitialDataFunction<
NonUndefinedGuard<InfiniteData<TQueryFnData, TPageParam>>to allow passing initialData as object and not within a callback function?
There was a problem hiding this comment.
we can pass initialData as an object via DefinedInitialDataInfiniteOptions:
query/packages/react-query/src/infiniteQueryOptions.ts
Lines 41 to 45 in febbde6
There was a problem hiding this comment.
sure, but it still won't work conditionally, see this modified playground based on the original example:
There was a problem hiding this comment.
okay then what’s the fix please 😅
There was a problem hiding this comment.
I made a PR here :) #8157
Hope that clarifies things, or perhaps I'm misunderstanding something!
|
thanks for addressing my issue so quickly! i added a post-merge comment with a potential overlook. :) |
Issue fix : #8132
There was a typescript error(but could be run with no problem) when using optional
initialDataininfiniteQueryOptions