I'm just learning Redux and I have a problem.
I have actions:
export const getValues = () => async (dispatch) => {
try {
const res = await axios.get(`/values`);
dispatch({
type: VALUE_STATE,
payload: res.data,
});
} catch (err) {
console.log(err);
}
};
export const getUsers = () => async (dispatch) => {
try {
const res = await axios.get(`/users`);
dispatch({
type: ALL_USER,
payload: res.data,
});
} catch (err) {
console.log(err);
}
};
COMPONENT
const handleClick = () => {
dispatch(getValues());
dispatch(getUsers());
};
Why, when I dispatch, they are triggered in the wrong order, sometimes in the right order ?