Redux state mutation error from action to reducer
up vote
0
down vote
favorite
I getting following error when I tried to change the value in control.
Uncaught (in promise) Error: A state mutation was detected between
dispatches, in the pathtest
. This may cause incorrect behavior.
Below is the code
Reducer
export default function testReducer(state = {}, action) {
switch (action.type) {
case types.UPDATE_TEST_SUCCESS:
return {
...state,
test: action.test
};
default:
return state;
}
}
Action
export function saveTest(testData) {
return function(dispatch) {
return testApi.testExam(testData).then(savedData => {
dispatch(updateTestSuccess(savedData));
});
};
}
export function updateTestSuccess(exam) {
return { type: types.UPDATE_Test_SUCCESS, exam };
}
API
static saveTest(testData) {
let url = services.GET_Test_URL;
return fetch(url, {
method: 'PUT',
body: JSON.stringify(testData).toString(),
dataType : "json",
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
}
}).then((response) => response.json())
.then((testD) => Object.assign({}, testD))
.catch((error) => { throw (error); });
}
reactjs redux react-redux
add a comment |
up vote
0
down vote
favorite
I getting following error when I tried to change the value in control.
Uncaught (in promise) Error: A state mutation was detected between
dispatches, in the pathtest
. This may cause incorrect behavior.
Below is the code
Reducer
export default function testReducer(state = {}, action) {
switch (action.type) {
case types.UPDATE_TEST_SUCCESS:
return {
...state,
test: action.test
};
default:
return state;
}
}
Action
export function saveTest(testData) {
return function(dispatch) {
return testApi.testExam(testData).then(savedData => {
dispatch(updateTestSuccess(savedData));
});
};
}
export function updateTestSuccess(exam) {
return { type: types.UPDATE_Test_SUCCESS, exam };
}
API
static saveTest(testData) {
let url = services.GET_Test_URL;
return fetch(url, {
method: 'PUT',
body: JSON.stringify(testData).toString(),
dataType : "json",
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
}
}).then((response) => response.json())
.then((testD) => Object.assign({}, testD))
.catch((error) => { throw (error); });
}
reactjs redux react-redux
Probably related to React and Redux: Uncaught Error: A state mutation was detected between dispatches
– Matheus Reis
Nov 9 at 2:03
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I getting following error when I tried to change the value in control.
Uncaught (in promise) Error: A state mutation was detected between
dispatches, in the pathtest
. This may cause incorrect behavior.
Below is the code
Reducer
export default function testReducer(state = {}, action) {
switch (action.type) {
case types.UPDATE_TEST_SUCCESS:
return {
...state,
test: action.test
};
default:
return state;
}
}
Action
export function saveTest(testData) {
return function(dispatch) {
return testApi.testExam(testData).then(savedData => {
dispatch(updateTestSuccess(savedData));
});
};
}
export function updateTestSuccess(exam) {
return { type: types.UPDATE_Test_SUCCESS, exam };
}
API
static saveTest(testData) {
let url = services.GET_Test_URL;
return fetch(url, {
method: 'PUT',
body: JSON.stringify(testData).toString(),
dataType : "json",
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
}
}).then((response) => response.json())
.then((testD) => Object.assign({}, testD))
.catch((error) => { throw (error); });
}
reactjs redux react-redux
I getting following error when I tried to change the value in control.
Uncaught (in promise) Error: A state mutation was detected between
dispatches, in the pathtest
. This may cause incorrect behavior.
Below is the code
Reducer
export default function testReducer(state = {}, action) {
switch (action.type) {
case types.UPDATE_TEST_SUCCESS:
return {
...state,
test: action.test
};
default:
return state;
}
}
Action
export function saveTest(testData) {
return function(dispatch) {
return testApi.testExam(testData).then(savedData => {
dispatch(updateTestSuccess(savedData));
});
};
}
export function updateTestSuccess(exam) {
return { type: types.UPDATE_Test_SUCCESS, exam };
}
API
static saveTest(testData) {
let url = services.GET_Test_URL;
return fetch(url, {
method: 'PUT',
body: JSON.stringify(testData).toString(),
dataType : "json",
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
}
}).then((response) => response.json())
.then((testD) => Object.assign({}, testD))
.catch((error) => { throw (error); });
}
reactjs redux react-redux
reactjs redux react-redux
edited Nov 9 at 1:58
asked Nov 9 at 0:05
Parag Pathari
5118
5118
Probably related to React and Redux: Uncaught Error: A state mutation was detected between dispatches
– Matheus Reis
Nov 9 at 2:03
add a comment |
Probably related to React and Redux: Uncaught Error: A state mutation was detected between dispatches
– Matheus Reis
Nov 9 at 2:03
Probably related to React and Redux: Uncaught Error: A state mutation was detected between dispatches
– Matheus Reis
Nov 9 at 2:03
Probably related to React and Redux: Uncaught Error: A state mutation was detected between dispatches
– Matheus Reis
Nov 9 at 2:03
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53217979%2fredux-state-mutation-error-from-action-to-reducer%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Probably related to React and Redux: Uncaught Error: A state mutation was detected between dispatches
– Matheus Reis
Nov 9 at 2:03