expo 弹出 - 在 redux 配置文件中超出最大调用堆栈
expo ejected - inside redux config file Maximum call stack exceeded
是expo弹出的项目
调试版本运行不佳但不崩溃,发布版本在弱设备上崩溃。(例如:iPhone 5、iPhone 6、iPhone 7 和类似设备)
崩溃结果 return 错误代码“超出最大调用堆栈”。(我知道这意味着循环。)对于 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”,
- "世博会": "40.0.0",
- "react-native": "~0.63.4",
- "@react-native-async-storage/async-storage": "1.15.13",
- "react-redux": "7.2.4",
- "redux": "4.1.2",
- "redux-devtools-extension": "2.13.9",
- "redux-persist": "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',
}
是expo弹出的项目
调试版本运行不佳但不崩溃,发布版本在弱设备上崩溃。(例如:iPhone 5、iPhone 6、iPhone 7 和类似设备)
崩溃结果 return 错误代码“超出最大调用堆栈”。(我知道这意味着循环。)对于 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”,
- "世博会": "40.0.0",
- "react-native": "~0.63.4",
- "@react-native-async-storage/async-storage": "1.15.13",
- "react-redux": "7.2.4",
- "redux": "4.1.2",
- "redux-devtools-extension": "2.13.9",
- "redux-persist": "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',
}