当我在android设备中运行我的React Native代码时,出现以下错误。
“存储区没有有效的reducer。请确保传递给CombineReducers的参数是一个值为reducer的对象。”
这是我的authReducer.js和rootReducer.js 请帮助我解决此问题。我也在这个项目中使用redux-persist。 谢谢。
//authReducer.js
import { createReducer } from "reduxsauce";
import {
LOG_IN_USER,
LOG_IN_USER_SUCCESS,
LOG_IN_USER_FAILURE
} from "../actions/Auth.actions";
export type AuthState = {
authData: ?AuthData,
isLoading: boolean,
authError: any,
isSigningOut: boolean,
signoutError: any,
isLoggingIn: boolean,
loginError: any
};
export const INITIAL_STATE: AuthState = {
authData: null,
isLoading: false,
authError: null,
isSigningOut: false,
signoutError: null,
isLoggingIn: false,
loginError: null
};
export const loginUser = (
state: AuthState = INITIAL_STATE,
{ payload: UserLoginData }
): AuthState => {
return {
...state,
isLoggingIn: true
};
};
export const loginUserSuccess = (
state: AuthState = INITIAL_STATE,
{ payload: { data } }
): AuthState => {
return {
...state,
isLoggingIn: false,
authData: data,
loginError: null
};
};
export const loginUserFailure = (
state: AuthState = INITIAL_STATE,
{ payload: error }
): AuthState => {
return {
...state,
isLoggingIn: false,
loginError: error
};
};
const ACTION_HANDLERS = {
[LOG_IN_USER]: loginUser,
[LOG_IN_USER_SUCCESS]: loginUserSuccess,
[LOG_IN_USER_FAILURE]: loginUserFailure
};
export default createReducer(INITIAL_STATE, ACTION_HANDLERS);
//rootReducer.js
import {combineReducers} from 'redux';
import authReducer from '../modules/auth/reducers/reducer'
export default rootReducer = combineReducers({
auth: authReducer
})