Why is my gearbox not updating the state of my store using ImmutableJS?

I have this code in my reducer

            const copy_states       = fromJS(state);

            const i_copy_jobs        = copy_states.get('calendar_jobs').get(s_from_day_key).get(s_dept_id).get(s_job_id);
            let i_calendar_removed   = copy_states.get('calendar_jobs').deleteIn([s_from_day_key,s_dept_id,s_job_id]);
            const newstate           = copy_states.toJS();

            console.log("BEFORE",state,newstate);

            return newstate;

So, I use Immutable.js, what it basically does is make a copy of the state, getting the copied value, which will be used later. Then delete this value and return the restored state.

The log confirms that it really deleted the value. What I don't understand, I have a button on the first page to check if the state has changed. When I go and press the button, it says that the state remains unchanged, as well as other components that rely on it.

My other gearboxes work great. Am I missing something because of how I use Immutable here?

+4
source share
1

, ( , )

const copiedState = fromJS(state);
const copiedJobs = copiedState.getIn(['calendar_jobs', s_from_day_key, s_dept_id, s_job_id]);
const calendarRemoved = copiedState.deleteIn(['calendar_jobs', s_from_day_key,s_dept_id,s_job_id])
const newState = copiedState.toJS();
return newState;

, copiedState . ( copiedState ) , . , copiedState newState . i. console.log("BEFORE",state,newstate); , .

, , :

const copiedState = fromJS(state);
const copiedJobs = copiedState.getIn(['calendar_jobs', s_from_day_key, s_dept_id, s_job_id]);
const calendarRemoved = copiedState.deleteIn(['calendar_jobs', s_from_day_key,s_dept_id,s_job_id]);
const newState = calendarRemoved.toJS();
return newState;
+1

Source: https://habr.com/ru/post/1694375/


All Articles