1

I am running the ABP React Mobile code from https://abp.io/ and am receiving an unhandled promise exception when logging in to the mobile application.

Steps to replicate from scratch:

  1. Create an ABP project
  2. Migrate the DB
  3. Log in to web app
  4. Create user and log in to test if DB will update
  5. Set up Conveyor to get IP address for react front end
  6. Ran Yarn to init react project
  7. Opened react project and added IP and port from Conveyor to Environment.js
  8. Ran Yarn start
  9. Open Expo on iOS and open project
  10. Log in with Admin and User credentials

Note: I do not think that the key should be undefined, so checking if the value is undefined will not solve the problem, only confirm that the key is undefined and we already know this from the error.

Results in this error:

[Unhandled promise rejection: TypeError: undefined is not an object (evaluating 'delete state.activeLoadings[action.payload.key]')]
* src\store\reducers\LoadingReducer.js:10:6 in builder.addCase$argument_1
* http://10.0.0.192:19001/node_modules%5Cexpo%5CAppEntry.bundle?platform=ios&dev=true&hot=false&minify=false:211765:15 in <unknown>
* [native code]:null in <unknown>
* [native code]:null in reduce
- node_modules\redux\lib\redux.js:463:34 in combination
* http://10.0.0.192:19001/node_modules%5Cexpo%5CAppEntry.bundle?platform=ios&dev=true&hot=false&minify=false:228985:32 in <unknown>
- node_modules\redux\lib\redux.js:217:8 in dispatch
- node_modules\@redux-saga\core\dist\redux-saga-core.dev.cjs.js:1412:9 in <anonymous> 
* src\screens\Login\LoginScreen.js:52:8 in login.then.then$argument_0
- node_modules\react-native\node_modules\promise\setimmediate\finally.js:12:28 in then$argument_1
- node_modules\react-native\node_modules\promise\setimmediate\core.js:37:13 in tryCallOne
- node_modules\react-native\node_modules\promise\setimmediate\core.js:123:24 in setImmediate$argument_0
- node_modules\react-native\Libraries\Core\Timers\JSTimers.js:130:14 in _callTimer    
- node_modules\react-native\Libraries\Core\Timers\JSTimers.js:181:14 in _callImmediatesPass
- node_modules\react-native\Libraries\Core\Timers\JSTimers.js:441:30 in callImmediates- node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:387:6 in __callImmediates
- node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:135:6 in __guard$argument_0
- node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:364:10 in __guard 
- node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:134:4 in flushedQueue
* [native code]:null in flushedQueue
* [native code]:null in callFunctionReturnFlushedQueue

Code related to error:

import { createReducer } from '@reduxjs/toolkit';
import LoadingActions from '../actions/LoadingActions';

const initialState = { activeLoadings: {}, loading: false };

export default createReducer(initialState, builder =>
  builder
    .addCase(LoadingActions.start, (state, action) => {
      const { key, opacity } = action.payload;
      return {
        ...state,
        actives: { ...state.activeLoadings, [key]: action },
        loading: true,
        opacity,
      };
    })
    .addCase(LoadingActions.stop, (state, action) => {
      delete state.activeLoadings[action.payload.key];

      state.loading = !!Object.keys(state.activeLoadings).length;
    })
    .addCase(LoadingActions.clear, () => ({})),
);
  • Does this answer your question? [Checking if a key exists in a JavaScript object?](https://stackoverflow.com/questions/1098040/checking-if-a-key-exists-in-a-javascript-object) – jazb Jan 27 '21 at 04:48
  • I am still a little unclear on the problem, are you saying that the key variable in the builder.addCase() is undefined? I am not too clear on what this promise does exactly or why it would return undefined. – INeedHelpPlz Jan 27 '21 at 20:37
  • Bumping - Still need some help on this. I do not think that the key should be undefined, so checking if the value is undefined will not solve the problem, only confirm that the key is undefined and we already know this from the error. – INeedHelpPlz Feb 01 '21 at 03:28
  • The same question answered here: https://github.com/abpframework/abp/issues/7602 – Mehmet Erim Feb 08 '21 at 11:44

0 Answers0