3 ms·
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 usin
by afavour 4y ago
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.
- harel 4y agouseEffect 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.