I have a React / Redux application and am using redux-logger
to show the state changes. I have some strange behaviour, wherby the resulting state contains an _id
property. For example, this information below shows my output from the logger:
prev state:
{
title: ""
}
action object:
{
title: "New title"
}
next state:
{
_id: ObjectID,
title: "New title"
}
Below is my reducer function:
function updateState(state = initialState.obj, action) {
switch (action.type) {
case 'SET_TITLE':
var newState = Object.assign({}, state, action.obj);
return newState;
default:
return state;
}
}
and initialState
is:
{
obj: {
title: ""
}
}
and the action payload is:
{
type: 'SET_TITLE',
obj: {
title: "New Title"
}
}
and the dispatcher is as follows:
// Call to API to get data from MongoDB...
let dataObj = response.data;
let newObj = {
title: dataObj.title
};
dispatch({
type: 'SET_TITLE',
obj: newObj
});
Why is the _id
propery being added?