2
나는 다음과 같은 오류지고있어 외부 관측 값을 변경 :가 Mobx 행동
proxyConsole.js:54 Error: [mobx] Invariant failed: Since strict-mode is enabled, changing observed observable values outside actions is not allowed. Please wrap the code in an `action` if this change is intended. Tried to modify: [email protected]
at invariant (mobx.module.js:2326)
at fail (mobx.module.js:2321)
at checkIfStateModificationsAreAllowed (mobx.module.js:2890)
at ObservableValue../node_modules/mobx/lib/mobx.module.js.ObservableValue.prepareNewValue (mobx.module.js:796)
at setPropertyValue (mobx.module.js:1673)
at Object.set [as items] (mobx.module.js:1641)
at Store.js:41
at <anonymous>
을하지만 내가 action
에서 함수를 포장하고 그래서 조금 혼란 스러워요 :
import { observable, useStrict, action } from 'mobx';
import Services from './Services';
// ...
getAllTodos: action(() => {
Services.getAllTodos()
.then((response) => {
state.items = response.data;
}).catch((error) => {
console.error(error);
});
}),
서비스 .js
// ...
getAllTodos() {
return axios.get(root + '/items/');
}
무엇이 여기에 있습니까?