I have a Redux Action but I can′t make it work . I need to find the index of an object which nested into an array of a firebase collection. After getting the data from the DB, I calculate the index but can′t send it to redux. It′s probably a super noob JavaScript mistake, I don′t know why but i can′t update the object that I am sending to redux (reDatos)
export const calcularIdsAModificar = (MOid) => {
let reDatos = {
MOid: MOid,
MOidindex: null,
};
return (dispatch, getState, { getFirebase, getFirestore }) => {
const Firestore = getFirestore();
const authorId = getState().firebase.auth.uid;
let experienciasArray = 'sin datos';
Firestore.collection('users')
.doc(authorId)
.get()
.then((resp) => {
experienciasArray = resp.data().experiencia;
let newindex = experienciasArray.findIndex((expe) => expe.id === MOid);
reDatos['MOidindex'] = newindex;
})
.then(dispatch({ type: 'ONCLICK_EDITAR_EXPERIENCIA', reDatos: reDatos }));
};
};