I am new to redux and I would like to create a middleware to get the number variable from previous state and current state then compare the numberif the value of number is the same, it would not call the useSelector(action). I use getState
under async that I can get current state value. However, how can I get previous state value? I do not want to use mapStateToProps
as I only want to create some function to help me to achieve the compare logic
export const shouldSetNumber = () => { return async (dispatch, getState) => { const current = getState()?.number || 0; console.log(current); useSelector(setNewNumber(current)) };};