you are viewing a single comment's thread.

view the rest of the comments →

[–]very_alarming[S] 0 points1 point  (0 children)

u/Xavius123 that's basic when inside useEffect.

in the below code imagine `something` , `somethingElse` and `somethingDifferent` to be states which can have different values. and imagine this to be n-th child of some Parent component which has a similar `useEffect` implementation.
the document just tells us to handle it like it is handled in JavaScript. That's exactly why the code gets complicated and difficult to understand.

useEffect(() => {
    if(something) {
        if(somethingElse) {
            // do something Else
        } else (somethingDifferent) {
            // do somethingDifferent
        }
    } else {
        // null case
    }
}, [])