How to save the object in Redux store?

In redusere displays the xhr object xhr, file - the file object, but the final state contains only empty objects. What is the error?
[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 here.displays the xhr object xhr, file - the file object
 return {
...contact,
 draft: {
...contact.draft,
 files: {
...contact.draft.files
 [fileId]: {
file
 loading: true,
 progress: 0,
xhr,
},
},
},
};
}
 return contact;
}),
};
 },
March 23rd 20 at 18:57
1 answer
March 23rd 20 at 18:59
Was not considered an immutable package to work with stor?
Then your reducer might look like this:
import {Map} from 'immutable';

const DROP_CACHE_DATA = 'DROP_CACHE_DATA';
export const coreActionCreators = {
 dropCacheData() {
 return {
 type: DROP_CACHE_DATA
}
}
}

export const core = (state = initialCoreState, action) => {

 switch (action.type) {

 case DROP_CACHE_DATA:
 return state
 .set('loadingDictionaries', false)
 .set('initDictionaries', false);
}
}


if you only need to change a property of an object:
state.setIn([objectName objectProp], value) - carmella.Blick6 commented on March 23rd 20 at 19:02

Find more questions by tags ReduxReactJavaScript