Answer the question
In order to leave comments, you need to log in
How to save an object in the redax store?
In the reducer, xhr outputs an xhr object, file outputs a file object, but the resulting state contains only empty objects. Where is the mistake?
[fileId]: {
file: {},
loading: true,
progress: 0,
xhr: {},
},
UPLOAD_FILE_REQUEST(state, payload) {
const {
contactIndex,
fileId,
file,
xhr,
} = payload;
return {
...state,
contacts: state.contacts.map((contact, index) => {
if (index === contactIndex) {
console.log('-->', payload); // здесь payload.xhr выводит объект xhr, file - объект file
return {
...contact,
draft: {
...contact.draft,
files: {
...contact.draft.files,
[fileId]: {
file,
loading: true,
progress: 0,
xhr,
},
},
},
};
}
return contact;
}),
};
},
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question