3 ms·
For a deep dive: https://dev.to/n1ru4l/homebrew-react-hooks-useasynceffect-or-how-to-handle-async-operations-with-useeffect-1fa8 https://dev.to/n1ru4l/homebrew-
by TurningCanadian 7y ago
For a deep dive:
https://dev.to/n1ru4l/homebrew-react-hooks-useasynceffect-or-how-to-handle-async-operations-with-useeffect-1fa8 https://dev.to/n1ru4l/homebrew-react-hooks-useasynceffect-or...
I think the current best answer is https://github.com/n1ru4l/use-async-effect https://github.com/n1ru4l/use-async-effect
But as noted by your SO question, Suspense for data fetching is what we're waiting for. It was originally scheduled to be released the middle of this year but was delayed.
https://reactjs.org/blog/2019/08/08/react-v16.9.0.html#an-update-to-the-roadmap https://reactjs.org/blog/2019/08/08/react-v16.9.0.html#an-up...
- mmatants 7y agoI'd say for 95% of data fetches https://github.com/slorber/react-async-hook https://github.com/slorber/react-async-hook works really well without needing generator syntax or explicit promise cancellation boilerplate. I'm not the author but a satisfied user.