我的react / redux应用程序出现问题,特定操作buildModalForm()
未从actions/index/
传递到reducer。我很反应,所以不确定问题是什么。
在container / buidpage中:
class BuildPage extends Component {
componentWillMount(){
this.props.fetchAPIJobs();
this.props.buildModalForm();
}
//....
const mapStateToProps = (state) => {
return {
rowData : state.buildJobs.rowData,
columns : state.buildJobs.columns,
reactView: state.reactView
}
}
const mapDispatchToProps = (dispatch) => {
return {
onFormClick: () => {
dispatch( showModal() )
},
onModalClose: () => {
dispatch( hideModal() )
},
buildModalForm : () => {
dispatch( buildModalForm() )
},
fetchAPIJobs : () => {
fetchAPIJobs(fetchAPIJobs())
}
}
}
export default connect(mapStateToProps, mapDispatchToProps)(BuildPage)
在actions / index中:
import * as actionTypes from '../constants/actionTypes'
export function buildModalForm(){
console.log("in action creator buildModalForm");
return { type: actionTypes.BUILD_MODAL_FORM }
}
in constants / actionTypes:
export const BUILD_MODAL_FORM = 'BUILD_MODAL_FORM'
在reducers / reactView中:(连接到根减速器)
import {
HIDE_MODAL,
SHOW_MODAL,
BUILD_MODAL_FORM
} from '../constants/actionTypes.js'
import {
BUILD_INITIAL_STATE,
ROOT_INITIAL_STATE
} from '../constants/initialStates'
export default function reactView(state = {}, action) {
console.log("in react view reducer :", action.type);
switch (action.type){
case SHOW_MODAL :
return Object.assign( {}, state, {modalDisplay: true})
case HIDE_MODAL :
return Object.assign( {}, state, {modalDisplay: false})
case BUILD_MODAL_FORM :
return Object.assign( {}, state, BUILD_INITIAL_STATE)
default :
return state
}
}
actions / index中的console.log
将其记录在操作内部,reducer中的日志正在读取其他操作类型,但BUILD_MODAL_FORM
未传递记录。任何帮助我的赞赏。
答案 0 :(得分:0)
- 我做了一个拼写错误,并没有从中间件返回任何内容。案件结案,doh。