I'm working on react native application with redux, The reducer looks something like this,
reducer = {
dataA: {},
dataB: {},
laoding: false,
error: false
}
I have created a redux action which will update dataA object in reducer. I called the action from one of my react-native components in useEffect().
useEffect(() => {
dispatch(dataA())
}, [])
I haven't passed any dependency array.
Everything works great, But from the same component where I explicitly dispatching an action to update dataB object which will incur update the dataA from the backend itself.
I'm expecting that, whenever i dispatch an action explicitly to update the dataB, the useEffect
should re-run to get the latest updated object values from dataA object.
But it is not happening, Even I try to pass dataA object as dependency to useEffect, it going an infinite loop of useEffect.
And also, dataB object consists boolean value which i want to display alert box when ever i dispatch an action to update dataB.
dataB = {
result: {
success: true || false,
Message: "Something"
}
}
thanks in advance