How to clear (reset) all data in dav.js

topic description

how to clear (reset) all data in dav.js

sources of topics and their own ideas

the project is now large and there is a lot of mdels data in dav. How to reset all current store data after exiting?

davgithub

Jul.07,2021

take the official example:

const initialState = [];
export default {
  namespace: 'products',
  state: initialState,
  reducers: {
    'delete'(state, { payload: id }) {
      return state.filter(item => item.id !== id);
    },
  },
};

the data that needs to be reproduced is:

const initialState = [];
export default {
  namespace: 'products',
  state: initialState,
  reducers: {
    'delete'(state, { payload: id }) {
      return state.filter(item => item.id !== id);
    },
    'reset'(state) {
      return state = initialState;
    }
  },
};
Menu