3 ms·
I came across this problem the other day: https://stackoverflow.com/questions/53332321/react-hook-warnings-for-async-function-in-useeffect-useeffect-function-m
by arcturus17 7y ago
I came across this problem the other day:
https://stackoverflow.com/questions/53332321/react-hook-warnings-for-async-function-in-useeffect-useeffect-function-must-ret https://stackoverflow.com/questions/53332321/react-hook-warn...
I love React and my first experience with hooks has been mostly positive, but how is it that something as simple as data fetching is not completely sorted out by now?
It sounds abhorrent!
- TurningCanadian 7y agoFor 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.