3 ms·
And if instead of calculating 2+2 you call into some world state (or return a deferred call along with your JSX, doesn't matter), then that is a side effect. Pe
by the_gipsy 4y ago
And if instead of calculating 2+2 you call into some world state (or return a deferred call along with your JSX, doesn't matter), then that is a side effect. Period. The main effect is returning JSX (html and some event->callback descriptors), which could be pure.
useEffect is a side effect in a render function. Not all side effects are useEffect in a render function, good job.
- robertoandred 4y agoNot sure how this got so absurdly reductionist. The fact remains, you do not need to use useEffect to fetch data in React. And useEffect runs after rendering, so you'd be delaying the fetch for no reason.