After using hooks, I just can't go back to Class component life cycle methods, which I had to look up everytime for method definitions, what props/states are passed to each.
useEffect became more natural as I don't have to figure out when it's called and can control when it's called.
To make a comparison, old class component life cycle methods reminds me of old ASP.NET Web forms, which had its life cycle methods, such as page load, page unload, etc and ASP.NET MVC rid that issue.
And async method callback for useEffect will trigger a warning.
Hi Ian,
After using hooks, I just can't go back to Class component life cycle methods, which I had to look up everytime for method definitions, what props/states are passed to each.
useEffect
became more natural as I don't have to figure out when it's called and can control when it's called.To make a comparison, old class component life cycle methods reminds me of old ASP.NET Web forms, which had its life cycle methods, such as page load, page unload, etc and ASP.NET MVC rid that issue.
And
async
method callback foruseEffect
will trigger a warning.Homebrew React Hooks: useAsyncEffect Or How to Handle Async Operations with useEffect
Laurin Quast ・ Jul 5 ・ 7 min read
Also discussed here
Async useEffect is pretty much unreadable #14326
The only alternative is using
then()
chains which aren't very readable at their own.