我有一個減速,看起來像這樣:mapStateToProps沒有反映在組件動作發出後
export default function reducer(state={
fetching: false,
}, action) {
switch (action.type) {
case 'LOGIN_REQUEST': {
return {...state, fetching: true}
}
...
return state
我從compoenent派遣行動,並在部分我:
const mapStateToProps = (state) => {
return state
}
我的問題是:
1.在mapStateToProps
狀態包含login.fetching: true
2.在組件調整後立即對還原器this.props.login.fetching
包含false
。
3.在組件render()
方法this.props.login.fetching
是true
。
爲什麼在案件2.它仍然是false
,這是可能的,我在這裏失蹤?
行動派遣:
onLoginPress =() => {
this.props.dispatch(loginUser(this.state.email.trim(), this.state.password.trim()))
console.log(this.props);
您能否特別在您的調度行動中顯示您的組件的代碼 – bencrinkle
更新的問題 – 1110
我不希望在您的調度反映狀態變化後直接看到道具。那隻會出現在重新渲染上,它的聲音就是你所看到的? – bencrinkle