Error when using `actionOn` not at the top level
alberteddu opened this issue · comments
Hey there! Loving the library so far. Having a problem with actionOn
.
When using actionOn
on a nested object, the state argument of the first function is undefined.
const store = createStore({
name: "",
act: action((state) => (state.name = "Name")),
deep: {
thing: actionOn(
(state) => state.act, // <--- state is undefined
() => {}
)
}
});
See an example here.
I'm not sure if this is expected—I could not find anything on the documentation.
Now I see what I missed — I should have used the second argument. It seems to be working with:
(nestedState, state) => state.act, // <--- state is not undefined
Sorry for the false alarm!