add pre event and pass previous state as argument.