
How can I update different module?
@1alexvash
Can you elaborate more in detail what exactly you are trying to accomplish? Are you trying to add a new fruit?
@1alexvash you can update nested state within the action.
Actions receive the state local to them, which includes the state below them too.
We can complete your code like so:
const store = createStore({
products: {
fruits: ["馃崗", "馃崐", "馃崒"],
},
addFruit: action((state, payload) => {
state.products.fruit.push(payload);
}),
});
store.getActions().addFruit("馃崏");
馃槉
Most helpful comment
@1alexvash you can update nested state within the action.
Actions receive the state local to them, which includes the state below them too.
We can complete your code like so:
馃槉