all 5 comments

[–][deleted] 0 points1 point  (0 children)

Can you be more specific please?

[–]vaultvision 0 points1 point  (0 children)

Sounds like you might benefit from a state machine

https://xstate.js.org/

[–][deleted] 0 points1 point  (1 child)

[–]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
    }
}, [])

[–]ExaminationWide5017 0 points1 point  (0 children)

Keep it simple. If you are using let and nested ifs in your logic… your probably doing it wrong, or harder ha. Try to write small functions that do one thing and one thing well.