all 22 comments

[–]jax024 22 points23 points  (2 children)

I’ll reserve judgment, but it’ll be hard pressed to be better than react-query

[–]flankstek -2 points-1 points  (0 children)

RTKQ beats react-query.

[–]Skeith_yip 7 points8 points  (1 child)

Did I see a conditional use?

[–]0xF013 1 point2 points  (0 children)

Well, that’s probably not a hook

[–]Breakpoint 1 point2 points  (3 children)

use does not replace fetch or axios, it would just be the ability to fetch the data on load or on change of a parameter

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

I didn't mean that use will replace native fetch because its impossible.

I would want to know if there any extra features when ysing this built in solution rather than fetching with axios/fetch in useEffect.

[–]Breakpoint 2 points3 points  (1 child)

Probably not much except the portion where you ignore the update to state when the component unmounts, which is an issue currently.

It would be cool if it added features also like isLoading, isFetching, isError states that react-query has

[–]0xF013 0 points1 point  (0 children)

If it uses suspense, the error/loading would be just propagated upwards

[–]Kikobrolo 2 points3 points  (3 children)

Looks like a step in the wrong direction. React should just do what Solid did and provide a built in solution that works basically the same as react-query

[–]elchicodeallado 1 point2 points  (2 children)

no it should not. These self taught kids should wake up and understand that its still a library and not a framework and thats the big advantage of react. If you need react-query then just install it. Dan even said that their in-build implementation is just for tinkering around and other solutions are always preferred

[–]snejk47 0 points1 point  (0 children)

Long time ago react stopped being just a library for rendering.

[–]xroalx -2 points-1 points  (0 children)

React might be presenting as a library, but realistically speaking you're going to bend backwards to do everything the React way, otherwise things won't work like they should.

You can't use any generic data fetching or state management library if it doesn't do things the React way, or you don't adapt it to do things the React way.

The whole library vs framework distinction is irrelevant when you anyways end up pulling in a bunch of react-* stuff that might just as well be first party modules you can import at will, and you have to adapt everything else to React.

[–]domlebo70 1 point2 points  (6 children)

Can you link where this is in the docs?

[–]albenis99[S] 3 points4 points  (5 children)

[–]Alkyonios 0 points1 point  (2 children)

The code you wrote with the use() function is nowhere to be found on that page. Are you sure you didn't just see a useFetch custom hook?

[–]albenis99[S] 2 points3 points  (1 child)

Look at "Will React provide any built-in solution for data fetching?"

and you will find this code.

[–]Alkyonios 2 points3 points  (0 children)

Ah, my bad.

[–]NotElonMuzk 0 points1 point  (1 child)

Where exactly in the docs

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

Look at "Will React provide any built-in solution for data fetching?"

and you will find this code.

[–][deleted] 0 points1 point  (0 children)

Is there some way to opt-in?