The method in Ant Design Pro Model's effects has the same name, resulting in an infinite loop. what is the reason for this?

the An and B codes of both models are the same, as follows:

export default {
  namespace: "A  B ",
  state: {}

  effects: { 
    *add({payload},  {call, put}){
        console.log("")
        yield put({
            type: "add",
            payload:{
                payload
            }
        });
    }
  },
  reducers:{
      add(state, action){
        console.log("state")
        return state;
      }
  }
};
When using

, it is not introduced at the same time. When I call a component, I print the above two contents in an endless loop.

if I am not in effects call put , there will be no endless loop.
I would like to ask all of you to answer the reason for this. Thank you.

Mar.20,2021

the add in your effects calls add, himself. If you don't use put, you won't call add. Of course, you won't have a dead loop.


Don't repeat your name. Thank you. There are more saveXxx operations in reducers.

Menu