我有減速象下面這樣:反應,終極版:`state.get`不是一個函數
// SignIn.js
const signIn = (state = {
mobilePhone: {
signInWay: 'email',
countryCallingCode: '+65'
}
}, action) => {
switch (action.type) {
case 'SIGN_IN':
return Object.assign({}, state, action.signInForm);
default:
return state;
}
};
export default signIn;
// UserInput.js
const userInput = (state = {}, action) => {
switch (action.type) {
case 'USER_INPUT':
return Object.assign({}, state, action.kv);
default:
return state;
}
};
export default userInput;
// Then index.js
import { combineReducers } from 'redux';
import userInput from './UserInput';
import signIn from './SignIn';
const gateApp = combineReducers({
userInput,
signInForm: signIn
});
export default gateApp;
然後在mapStateToProps
,當我試圖做
const mapStateToProps = (state) => {
console.log(state)
return {
signInForm: state.get('signInForm')
};
};
我得到錯誤: SignIn.js:9 Uncaught TypeError: state.get is not a function
,我登出的狀態對象,它給了我這樣的事情:
哪裏出問題了?
您可以嘗試使用'state.signInForm' –