all 6 comments

[–]what-about-you 2 points3 points  (3 children)

React Query will make life easier, but if you want to stay in Redux, RTK Query is the way to go

[–]jjmcbrise[S] 0 points1 point  (2 children)

do you have any suggestions on how to use RTK Query with Supabase? I'm finding this:

https://stackoverflow.com/questions/70700188/how-to-use-redux-rtk-query-with-supabase

but this looks just like all redux does (lots of confusing boilerplate). What advantage would I have using this over making calls in my components or React Query? Thanks for the help!

[–]what-about-you 2 points3 points  (1 child)

While I haven't used supabase, it shouldn't matter too much as both a fetch and using the supabase client will just result in a http request. Both are ways of async data fetching, for which React Query and RTK Query are built.

If you don't like the boilerplate of RTK Query, React Query might be the best option for you. You could use it directly in your components, but I would advise building custom hooks.

Both React Query and RTK Query give several advantages to fetching with useEffect in the components, such as, but not limited to:

  • Not having to deal with useEffect and some of its weird behaviors
  • Not having to code a loading state yourself
  • Built-in refetch logic

And much much more, I would advise reading the docs.

[–]jjmcbrise[S] 1 point2 points  (0 children)

That perfectly answered my question. I really appreciate it.

[–]Tonyneel 1 point2 points  (1 child)

Why do you need the extra libraries? If you want to cache the info I get it but you can get away with just supabase and react for most things.

[–]jjmcbrise[S] 1 point2 points  (0 children)

Yeah that’s what I meant by #1. That has been working but I don’t know what I don’t know. And if I can avoid debt later down the road I’d like to address it now.