Dva @ connect injects props into the component only after the value is undefined

problem description

use @ connect of dva to inject props into the component in antdpro, and the component takes the print this.props to see that the injected value is undefined;

the environmental background of the problems and what methods you have tried

component code
@ connect (({testData, loading}) = > ({
testData,
loading: loading.effects ["test/fetchTestData"],
}))

class Test extends React.Component {
state = {

data: []

}

componentDidMount () {

const { dispatch } = this.props;
  dispatch({
    type: "test/fetchTestData"
});

}

render () {

console.log(this.props)//Propsundefined
...

< hr >

models Code
import {queryTestData} from"@ / services/api";

export default {
namespace: "test",

state: {

testData:[]

},

effects: {

*fetchTestData({ payload }, { call, put }) {
  const response = yield call(queryTestData, payload);//fetch
  console.log(response)//mock
  yield put({
    type: "getData",
    payload: response,
  });
},

},

reducers: {

getData(state, { payload }) {
  
  console.log(state,payload) //
  return {
    ...state,
    ...payload,
  };
},

},
};


has been solved. When the structural data in @ connect comes out, the received parameters are divided by namespace:...,.
so change
@ connect (({testData, loading})) = > ({
testData,
loading: loading.effects ['test/fetchTestData'],
})
to
@ connect (({test, loading}) = > ({
test,
loading: loading.effects [' test/fetchTestData']
})

)
Menu