The issue I've encountered is this:
export const state = () => ({
someState: 'foo',
});
export const actions = {
ACTION({ dispatch, commit }) {
// I forgot to destructure state in the function arguments
// so now I'm accessing the state function by accident
if (state.something) {
// .. never true
}
}
};
Allow state to be exported as initialState:
export const initialState = () => ({
someState: 'foo',
});
export const actions = {
ACTION({ dispatch, commit }) {
// Error can now be picked up by ESLint or will
// throw an error with state being undefined
}
};
I'd like to help with this issue 馃槉
Question: should we deprecate the old behavior, the export using the 'state' function name? Or should we use both - check for a 'state' function then check for a 'initialState' function?
Perhaps deprecate the state export but support both for now and then remove state in a future release to give plenty of time for migration
@manniL I would appreciate hearing your opinion on this, thanks!
@felubra Sorry, somehow I missed the notifications from that issue 馃
I would not deprecate state because the default VueX initialization structure should still work. It鈥檇 be a nice addition to accept initialState as well
As stated in #4096, this feature won't see the daylight.
Thanks for your efforts @felubra! :pray:
This feature-request has been cancelled by @manniL.
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Most helpful comment
@felubra Sorry, somehow I missed the notifications from that issue 馃
I would not deprecate state because the default VueX initialization structure should still work. It鈥檇 be a nice addition to accept
initialStateas well