Reactjs ';行动';未在reducer-React,Redux中定义

Reactjs ';行动';未在reducer-React,Redux中定义,reactjs,redux,Reactjs,Redux,我已经设置了一个减速机,但是控制台抱怨没有定义“action”no undef import { getName } from '../actions'; let defaultState={ name: "Sam" } const mainReducer=(state = defaultState, simpleAction)=>{ if (action.type === "CHANGE_NAME") { return{ ...state, name: action.name

我已经设置了一个减速机,但是控制台抱怨没有定义“action”no undef

import { getName } from '../actions';
let defaultState={
 name: "Sam"
}
const mainReducer=(state = defaultState, simpleAction)=>{
if (action.type === "CHANGE_NAME") {
return{
  ...state,
  name: action.name
}

} else {
return{
  ...state
}
}
}

export default mainReducer

只需将
simpleAction
更改为
action

执行以下操作:

import { getName } from '../actions';
let defaultState = { name: "Sam" }
const mainReducer = (state = defaultState, action) => {
    if (action.type === "CHANGE_NAME") {
        return { ...state, name: action.name }
    }
    else {
        return { ...state }
    }
}
export default mainReducer

它是
simpleAction
它应该是
(state=defaultState,action)