我有react-redux app 在开发过程中没有错误,但在生产中,它不起作用。
我已经完全删除了redux-dev-tolls等但没有机会。
我收到了这个错误;
TypeError: Cannot read property 'isLoading' of undefined
我声明signInStatus
和isLoading
里面的反应渲染函数就像这样;
const {signin, signInStatus} = this.props
const {
isLoading,
isSucceeded,
idErrorMessage,
passwordErrorMessage,
generalErrorMessage
} = signInStatus;
连接;
const reduxInjected = connect(({signInStatus}) => ({signInStatus}), {
signin,
signInResetForm,
signinStorage
})(LoginEmailPasswordForm);
....
减速器;
const signInStatus = (state = {isLoading: false, isSucceeded: false}, action) => {
switch (action.type) {
// Hot Module Replacement
case EPIC_END:
return {isLoading: false, isSucceeded: false};
case ...:
return {...state, isLoading: false, isSucceeded: false};
case ...:
case ...:
case ...:
return {isLoading: true, isSucceeded: false};
case ...:
case ...:
const {accessToken, idToken, expiresIn} = action;
let expiresAt = JSON.stringify((action.expiresIn * 1000) + new Date().getTime());
return {isSucceeded: true, token: {accessToken, idToken, expiresAt}};
case ...:
return {isSucceeded: true, isLoggedIn: true, token: action.token, user: action.user};
case ...:
return {}
case ...:
const newState = {}
const {error} = action;
...
return {...newState, isLoading: false, isSucceeded: false};
case ...:
return {...state, isLoggedIn: true, user: action}
case ...:
return {}
default:
return {...state}
}
}
您可以看到signInStatus具有初始状态,但它表示它是undefined
可能是什么原因?
谢谢。
答案 0 :(得分:0)
这是关于UglifyJsPlugin
plugins: [
// Don't Minify JS, redux doesn't like it
// new UglifyJsPlugin({
// sourceMap: true,
// compress: false,
// }),
],