I am new to react and just learned how to use useEffect and useState/useReducer. Now I am facing a problem. Assume I have a useEffect like below and states A,B,C,D:
React.useEffect(() => {
D = fetchReq(A, B, C);
}, [A, B, C])
React.useEffect(() => {
B = fetchReq(A)
}, [A])
React.useEffect(() => {
C = fetchReq(B)
}, [B])
The problem is B also depends on A, so everytime A gets update, B needs to update by an async req accordingly i.e B = fetchReq(A). And C depends on B, C = fetchReq(B). So once if A change, it may trigger incorrect behavior like fetchReq(A,B_old,C_old) or fetchReq(A,B,C_old), which is unwanted.
How should I fix this problem?