expo已弹出-在redux配置文件中超过了最大调用堆栈



这是expo弹出的项目。

调试版本工作不正常,但没有崩溃,发布版本在弱设备上崩溃。(例如:iPhone 5、iPhone 6、iPhone 7和类似设备(

崩溃结果返回错误代码";超过了最大调用堆栈";。(我知道这意味着循环。(对于iPhone 12或一些更好的设备,长时间的闪屏加载以及之后的加载。

我试着调试我的代码很长一段时间,但没有任何工作。

我只发现了一个结果,那就是删除代码中的所有内容,效果很好,但当我试图在redux配置文件中导入一些reducer时,所有内容都运行缓慢,在弱设备上崩溃。现在我不知道循环在哪里,我需要做什么。

import AsyncStorage from '@react-native-async-storage/async-storage';
import {createStore, combineReducers, applyMiddleware} from 'redux';
import ReduxThunk from 'redux-thunk';
import {persistStore, persistReducer} from 'redux-persist';
import AsyncStorage from '@react-native-async-storage/async-storage';
import * as ActionTypes from './types';
import {composeWithDevTools} from 'redux-devtools-extension';
import authReducer from './reducers/auth';
const persistConfig = {
key: 'root',
storage: AsyncStorage,
whitelist: [], // which reducer want to store
};
const appReducer = combineReducers({
auth: authReducer
});
const rootReducer = (state, action) => {
if (action.type === ActionTypes.AUTH_LOGOUT_REQUEST) {
state = undefined;
}
return appReducer(state, action);
};
const pReducer = persistReducer(persistConfig, rootReducer);
const middleware = applyMiddleware(ReduxThunk, apiMiddleware);
const store = createStore(pReducer, composeWithDevTools(middleware));
const persistor = persistStore(store);
export {store, persistor};

我的包裹:

  • "反应":"17.0.1〃
  • "expo":"40.0.0〃
  • "react native":"0.63.4〃
  • "react native async storage/async storage":"1.11.13">
  • "反应还原":"7.2.4">
  • "redux":"4.1.2">
  • "redux devtools扩展":"2.13.9〃
  • "redux persistent":"6.0.0〃
  • "redux thunk":"2.3.0">

我将操作类型放在.tsx(enum(文件中。

这是我的解决方案。

之前:

export const AUTH_LOGIN_REQUEST = '[Auth] Login request';
export const AUTH_LOGIN_SUCCESS = '[Auth] Login success';
export const AUTH_LOGIN_FAILURE = '[Auth] Login failure';

之后:

export const enum ActionTypes{
AUTH_LOGIN_REQUEST = '[Auth] Login request',
AUTH_LOGIN_SUCCESS = '[Auth] Login success',
AUTH_LOGIN_FAILURE = '[Auth] Login failure',
}

相关内容

最新更新