react-query-auth icon indicating copy to clipboard operation
react-query-auth copied to clipboard

Update: Migrate to Tanstack React Query 4 and dts

Open PointSingularity opened this issue 2 years ago • 1 comments

This PR updates many of the packages as well as migrates from react-query to the new tanstack/react-query. It also migrates from tsdx to dts, because tsdx is no longer maintained and dts is an active fork, which minimizes the amount of workflow changes.

  • Migrate from react-query to Tanstack React Query 4 (Query Keys need to be an Array)
  • Replace tsdx with dts-cli
  • Update to TS 4.8
  • Update to Storybook 6 with webpack 5 (starting SB shows a lot of warnings, but that is due the TS 4.8)
  • Fix some new typing issues in the sample app (there were a lot of null/undefined errors, needs a review)
  • Changed the version to 2.0.0, because it would be a breaking change

PS: Stackblitz example wasn't changed.

PointSingularity avatar Sep 19 '22 09:09 PointSingularity

Its so cool to see how popular TanStack Query has gotten these past couple of years. Love using it myself.

LinnJS avatar Sep 22 '22 12:09 LinnJS

@alan2207 any chance accepting this PR?

AO19 avatar Oct 18 '22 08:10 AO19

So happy someone did this. THANK YOU.

morrisonbrett avatar Nov 04 '22 18:11 morrisonbrett

I get the following issue when running this forked branch,

Error: No QueryClient set, use QueryClientProvider to set one

even though I have my client set on the component above, as soon as I remove the AuthProvider I no longer get the error. My setup is the same as the updated sample app.

samducker avatar Nov 13 '22 21:11 samducker

I get the following issue when running this forked branch,

Error: No QueryClient set, use QueryClientProvider to set one

even though I have my client set on the component above, as soon as I remove the AuthProvider I no longer get the error. My setup is the same as the updated sample app.

@samducker I just checked the sample app (storybook) and it works for me.

But I did try out this code

    <AuthProvider>
      <ReactQueryProvider>
        <App />
      </ReactQueryProvider>
    </AuthProvider>

Which produces the same error as yours: image

But you should try swapping the order of the two providers like this:

    <ReactQueryProvider>
      <AuthProvider>
        <App />
      </AuthProvider>
    </ReactQueryProvider>

That solved the error for me.

Hope this helps you!

PointSingularity avatar Nov 13 '22 22:11 PointSingularity

Hey @PointSingularity , thanks a lot for the PR, unfortunately, I already started migrating it myself but then didn't have time to finish until recently. It differs because it has a completely different API to fit more use cases.

I will close this PR in favor of #18

alan2207 avatar Jan 01 '23 17:01 alan2207

Hey @PointSingularity , thanks a lot for the PR, unfortunately, I already started migrating it myself but then didn't have time to finish until recently. It differs because it has a completely different API to fit more use cases.

I will close this PR in favor of #18

Hey, no problem 👍 #18 looks great!

PointSingularity avatar Jan 01 '23 17:01 PointSingularity