Hacker News new | past | comments | ask | show | jobs | submit login

I came across this problem the other day:

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!




For a deep dive: https://dev.to/n1ru4l/homebrew-react-hooks-useasynceffect-or...

I think the current best answer is 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-up...


I'd say for 95% of data fetches 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.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: