Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

The fact that “strict mode” means useEffect gets called twice feels like a great example of the ways in which React is not simple.

It’s not quite directly using a promise but I was surprised I can’t use an async function in useEffect. It’s pretty common to perform async operations there, after all.



useEffect IS a great (the best?) place to put async code. I do it all the time. The reason for strict mode rendering twice is to spot strictness related issues. Honestly I never even thought of using it so I've never experienced this.




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

Search: