Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Reactjs 我的数据返回给我带有传奇的原型对象Redux_Reactjs_Redux_Async Await_Redux Saga - Fatal编程技术网

Reactjs 我的数据返回给我带有传奇的原型对象Redux

Reactjs 我的数据返回给我带有传奇的原型对象Redux,reactjs,redux,async-await,redux-saga,Reactjs,Redux,Async Await,Redux Saga,我想获取我的操作状态:加载组但对象返回我 原型:对象 我的传奇 ##//SAGAS ## import { loadGroup } from "../actions/Group" export function* loadApiDataGroup() { try { // API const response = yield call(axios.get, 'http://localhost:8000/api/group'); yield put

我想获取我的操作状态:加载组但对象返回我 原型:对象

我的传奇

##//SAGAS ##
import { loadGroup } from "../actions/Group"

export function* loadApiDataGroup() {
  try {
    // API 
        const response = yield call(axios.get, 'http://localhost:8000/api/group');
        yield put(loadGroup(response))
  } catch (e) {
    console.log('REQUEST FAILED! Could not get group.')
    console.log(e)
  }
}

export default function* mySaga() {
  yield [
    loadApiDataGroup(),
  ]
}
actions.js

##// ACTIONS ##
export function loadGroup(data){ return { type: LOAD_GROUP, data }};

## // REDUCER ##
export default function groupReducer( state= {}, action = {}){
    switch (action.type){
        case LOAD_GROUP:
            return {
                ...state
            }
        default:
            return state
    }
}
root.js

## // ROOT REDUCERS ##
import groupReducer from '../actions/Group'

const reducer = combineReducers({
  groupReducer,
});
我的成分

## // COMPONENT ##
const mapStateToProps = (state, props) => {
    console.log(state., "CONSOLE LOG");
    return {
    }
};

const mapDispatchToProps = dispatch => {
    return { actions: bindActionCreators({ loadGroup }, dispatch)};
}

您的状态为空,因为您没有使用api调用的响应更新initialState。将减速机更新为“case LOAD_GROUP:return{……state,GROUP:action.data}`谢谢Brandon,就是这样!:)