【问题标题】:expo ejected - inside redux config file Maximum call stack exceededexpo 弹出 - 在 redux 配置文件中超过最大调用堆栈
【发布时间】:2022-01-07 05:07:30
【问题描述】:

是世博会退出项目。

debug 版本运行不好但不崩溃,release 版本在弱设备上崩溃。(例如:iPhone 5、iPhone 6、iPhone 7 和类似设备)

崩溃结果返回错误代码“超出最大调用堆栈”。(我知道这意味着循环循环。)对于 iPhone 12 或一些更好的设备启动画面加载很长时间,然后加载。

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

我只找到了一个结果,它删除了代码中的所有内容,它运行良好,但是当我尝试在 redux 配置文件中导入一些减速器时,一切运行缓慢并且在弱设备上崩溃。现在我不知道循环在哪里以及我需要做什么。

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”,

【问题讨论】:

    标签: react-native redux expo redux-thunk


    【解决方案1】:

    我将动作类型放在一个 .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',
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-01-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-10-24
      • 2015-12-29
      • 2017-12-27
      • 2020-12-06
      相关资源
      最近更新 更多