In below example, after I get data from firebase, I want to add user object which is already present in redux store and append it in all the message objects. Request you to help.
db.collection(`messages/${documentId}/chat`)
  .get()
  .then(snapshot => {
    const messages = [];
    snapshot.docs.forEach(doc => {
    console.log("message", doc.id, doc.data());
    messages.push({
      id: doc.id,
      from: doc.data().from,
      to: doc.data().to,   
      text: doc.data().text,
      timestamp: doc.data().timestamp.seconds * 1000
    });
  });
  dispatch({ type: GET_CHAT, payload: messages });
});
                if your using Redux Thunk middleware, you could simply do that:
const myAction = () => async (dispatch, getState) => {
  const { field1, field2 } = getState().myReducer;
};
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With