dai-shi / react-hooks-async

[NOT MAINTAINED] React custom hooks for async functions with abortability and composability

Home Page:https://www.npmjs.com/package/react-hooks-async

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Project maintenance and future of data fetching

Alxblsk opened this issue · comments

This is not an issue, but a topic for discussion. I noticed, that there is a message about the future of the repo.

Quote:

The approach this project takes is so-called useEffect chaining, which will not be a best practice in the future versions of React.

Is this a reference to Suspense, or it's a reference to some other way of fetching data I am not aware of?

You are welcome to open a discussion!
Yes, it means React Suspense. But, the useEffect chaining pattern is not tied to it. Basically, useEffect is delayed and slow, so we want to avoid using it.
The best practice before Suspense comes is to start a single async function in a callback.

This means, in this library, if you use only one useAsyncTask and task.start, it's fine and it follows the best practice. Using some of useAsyncCombine* will (intentionally) cause useEffect chains.

While this project is no longer maintained, I will continue my work on data fetching hooks. My plan is to revisit https://github.com/dai-shi/react-hooks-fetch work and eventually make it v1.

Thank you for explanation and references, @dai-shi.
I think it might be a decent Idea to reference this issue in that message so people can find more details about the future of data fetching in context of your hooks.

Sure, will do.