reduxjs / redux

A JS library for predictable global state management
https://redux.js.org
MIT License
60.75k stars 15.27k forks source link

React-native Redux not working in production. #4133

Closed dotsinspace closed 3 years ago

dotsinspace commented 3 years ago

Prior Issues

Redux only working when application is in development or switching off js bundle dev = unchecked in devloper menu. if try to build release than state is not working at all. app just stucks in one please.

NOTE: I am not using any navigation library. Have built own navigation system but thats too simple it only renders and unmount based on conditions nothing fancy.

What is the current behavior?

Index.js -> Account.Register.WithMobileNumber ( Stays Here even though everything is working accordingly )

What i expect ?

Index.js -> Account.Register.WithMobileNumber -> Index.js ( Will Update Remove RenderOver if account.authorization key is found )

Code

Package.json

{
  "name": "truckpe",
  "version": "0.0.1",
  "private": true,
  "workspaces": {
    "nohoist": [
      "**",
      "**/@sentry/react-native/**"
    ]
  },
  "scripts": {
    "clean": "react-native-clean-project && pnpm recursive run clean && rimraf node_modules pnpm-lock.yaml package-lock.json yarn.lock",
    "install::android": "react-native run-android",
    "install::ios": "react-native run-ios",
    "dev": "react-native start",
    "relay": "relay-compiler --src ./Pages --schema ./packages/schema/index.graphql",
    "test": "jest",
    "lint": "eslint ."
  },
  "dependencies": {
    "@apollo/client": "^3.3.14",
    "@manaflair/redux-batch": "^1.0.0",
    "@react-native-async-storage/async-storage": "^1.15.5",
    "@react-native-clipboard/clipboard": "^1.7.0",
    "@react-native-community/art": "^1.2.0",
    "@react-native-community/datetimepicker": "^3.4.3",
    "@react-native-community/geolocation": "^2.0.2",
    "@react-native-community/hooks": "^2.6.0",
    "@react-native-community/image-editor": "^2.3.0",
    "@react-native-community/netinfo": "^6.0.0",
    "@react-native-firebase/app": "^11.5.0",
    "@react-native-mapbox-gl/maps": "^8.2.0-beta1",
    "@sentry/cli": "^1.67.1",
    "@sentry/react-native": "^2.6.0",
    "@styled-system/theme-get": "^5.1.2",
    "@thang2162/react-native-tile-view": "^0.1.3",
    "apollo-upload-client": "^14.1.3",
    "appcenter": "^4.1.0",
    "appcenter-analytics": "^4.1.0",
    "appcenter-crashes": "^4.1.0",
    "cuid": "^2.1.8",
    "font-color-contrast": "^1.0.3",
    "google-geocode-parser": "^1.4.5",
    "immer": "^9.0.3",
    "lodash": "^4.17.21",
    "lottie-react-native": "^4.0.2",
    "moment": "^2.29.1",
    "patch-package": "^6.4.7",
    "prop-types": "^15.7.2",
    "react-icons-kit": "^1.3.1",
    "react-native-animatable": "^1.3.3",
    "react-native-animated-linear-gradient": "^1.2.2",
    "react-native-calendars": "^1.1260.0",
    "react-native-camera": "^3.43.5",
    "react-native-chooser": "^1.7.0",
    "react-native-color-matrix-image-filters": "^5.2.10",
    "react-native-dash": "0.0.11",
    "react-native-device-info": "^8.1.0",
    "react-native-document-picker": "^5.0.3",
    "react-native-dotenv": "^2.5.5",
    "react-native-error-boundary": "^1.1.9",
    "react-native-fast-image": "^8.3.4",
    "react-native-geocoding": "^0.5.0",
    "react-native-gesture-handler": "^1.10.3",
    "react-native-google-places": "^3.1.2",
    "react-native-i18n": "^2.0.15",
    "react-native-image-picker": "^3.3.2",
    "react-native-image-resizer": "^1.4.4",
    "react-native-image-viewing": "^0.2.0",
    "react-native-locale-listener": "^1.0.8",
    "react-native-maps": "^0.27.1",
    "react-native-maps-directions": "^1.8.0",
    "react-native-navbar-color": "^1.0.3",
    "react-native-otp-inputs": "^7.0.3",
    "react-native-otp-verify": "^1.0.4",
    "react-native-permissions": "^3.0.1",
    "react-native-progress": "^4.1.2",
    "react-native-pure-splash-screen": "^0.0.6",
    "react-native-push-notification": "^7.3.1",
    "react-native-reanimated": "^2.2.0",
    "react-native-responsive-dimensions": "^3.1.1",
    "react-native-restart": "^0.0.22",
    "react-native-shadow": "^1.2.2",
    "react-native-share": "^5.2.2",
    "react-native-simple-radio-button": "^2.7.4",
    "react-native-simple-toast": "^1.1.3",
    "react-native-skeleton-placeholder": "^4.0.0",
    "react-native-snap-carousel": "^3.9.1",
    "react-native-star-rating": "^1.1.0",
    "react-native-stopwatch-timer": "0.0.21",
    "react-native-svg": "^12.1.1-0",
    "react-native-swipe-gestures": "^1.0.5",
    "react-native-switch": "^2.0.0",
    "react-native-vector-icons": "^8.1.0",
    "react-native-vibration": "^0.2.0",
    "react-native-view-shot": "^3.1.2",
    "react-native-webview": "^11.3.2",
    "react-redux": "^7.2.3",
    "react-relay": "^11.0.1",
    "react-relay-network-modern": "^6.0.0",
    "redux": "^4.0.5",
    "redux-persist": "^6.0.0",
    "redux-persist-error-handler": "^0.1.1",
    "redux-persist-expire": "^1.1.0",
    "redux-reset": "^0.3.0",
    "redux-thunk": "^2.3.0",
    "redux-undo": "^1.0.1",
    "relay": "^0.8.0-1",
    "relay-hooks": "^4.2.0",
    "string": "^3.3.3",
    "styled-components": "^5.2.3",
    "styled-system": "^5.1.5",
    "subscriptions-transport-ws": "^0.9.18",
    "underscore": "^1.13.0",
    "use-state-if-mounted": "^1.0.4"
  },
  "devDependencies": {
    "@babel/core": "^7.13.15",
    "@babel/plugin-external-helpers": "^7.12.13",
    "@babel/plugin-proposal-export-default-from": "^7.12.13",
    "@babel/plugin-proposal-nullish-coalescing-operator": "^7.13.8",
    "@babel/plugin-proposal-optional-chaining": "^7.13.12",
    "@babel/plugin-proposal-throw-expressions": "^7.12.13",
    "@babel/plugin-syntax-dynamic-import": "^7.8.3",
    "@babel/plugin-transform-runtime": "^7.13.15",
    "@babel/runtime": "^7.12.10",
    "@babel/runtime-corejs3": "^7.13.10",
    "@react-native-community/eslint-config": "^2.0.0",
    "babel-jest": "^26.6.3",
    "babel-plugin-module-resolver": "^4.1.0",
    "babel-plugin-relay": "^11.0.1",
    "babel-plugin-root-import": "^6.6.0",
    "babel-plugin-styled-components": "^1.12.0",
    "eslint": "^7.24.0",
    "eslint-plugin-react-hooks": "^4.2.0",
    "get-yarn-workspaces": "^1.0.2",
    "graphql": "^15.5.0",
    "intl": "^1.2.5",
    "jest": "^26.6.3",
    "metro": "^0.65.2",
    "metro-react-native-babel-preset": "^0.65.2",
    "module-resolver": "^1.0.0",
    "proxy-polyfill": "^0.3.2",
    "react": "^17.0.2",
    "react-devtools-core": "^4.13.2",
    "react-dom": "^17.0.2",
    "react-native": "^0.64.1",
    "react-native-clean-project": "^3.6.3",
    "react-native-svg-transformer": "^0.14.3",
    "react-test-renderer": "^17.0.2",
    "relay-compiler": "^11.0.1",
    "relay-config": "^11.0.1",
    "relay-runtime": "^11.0.1"
  },
  "jest": {
    "preset": "react-native"
  }
}

Redux Manager

/*
 * IMPORTS
 */
import AsyncStorage from '@react-native-async-storage/async-storage' // Npm: react-native async storage.
import Thunk from 'redux-thunk' // Npm: redux thunk library.
import ExpireReducer from 'redux-persist-expire' // Npm: redux state expire.
import Undoable from 'redux-undo' // Npm: redux store undo redo library.
import ReduxReset from 'redux-reset' // Npm: utility for clearing redux store.
import { reduxBatch } from '@manaflair/redux-batch' // Npm: batched actions and reducers.
import { applyMiddleware, combineReducers, compose, createStore } from 'redux' // Npm: redux library.
import { persistReducer, persistStore } from 'redux-persist' // Npm: redux persist state library.

/*
 * SIBLINGS
 */
import { Theme } from './Reducers/Theme'
import { System } from './Reducers/System'

/*
 * GLOBALS
 */
let Manager

/*
 * OBJECTS
 */
const UndoableReducer = __reducer => {
  // Only proceed if reducer has name.
  if (__reducer.name) {
    // Const assignment.
    const _reducerName = __reducer.name.match(/[A-Z][a-z]+/ug).join('_').toUpperCase()

    /*
     * Register given reducer for undoable
     * work.
     */
    return Undoable(__reducer, {
      'ignoreInitialState': false,
      'undoType': `${_reducerName}_UNDO`,
      'redoType': `${_reducerName}_REDO`,
      'clearHistoryType': `${_reducerName}_CLEAR`,
      'syncFilter': true,
      'neverSkipReducer': true,
      'debug': true
    })
  }

  // Return reducer as is.
  return __reducer
}
const CreateReducerManager = initialReducers => {
  // Local Variable.
  let _combinedReducer, _keysToRemove

  // Create the initial combinedReducer
  _combinedReducer = combineReducers(initialReducers)

  // An array which is used to delete state keys when reducers are removed
  _keysToRemove = []

  // Return object.
  return {
    getReducerMap: () => initialReducers,

    /*
     * The root reducer function exposed by this object
     * This will be passed to the store
     */
    reduce(state, action) {
      // If any reducers have been removed, clean up their state first
      if (0 < _keysToRemove.length) {
        // Local variable.
        let kilo

        // Over Spreading.
        state = { ...state }

        // Remove key from state.
        for (kilo of _keysToRemove) delete state[kilo]

        // Reset container.
        _keysToRemove = []
      }

      /*
       * If reduce returns undefined than
       * return object instead.
       */
      return _combinedReducer(state, action)
    },

    // Adds a new reducer with the specified key
    add(key, reducer) {
      // Only add reducer if never existed before.
      if (!key || initialReducers[key]) return

      // Add the reducer to the reducer mapping
      initialReducers[key] = UndoableReducer(reducer)

      // Generate a new combined reducer
      _combinedReducer = combineReducers(initialReducers)
    },

    // Removes a reducer with the specified key
    remove(key) {
      // If key doesnt exit than return.
      if (!key || !initialReducers[key]) return

      // Remove it from the reducer mapping
      delete initialReducers[key]

      // Add the key to the list of keys to clean up
      _keysToRemove.push(key)

      // Generate a new combined reducer
      _combinedReducer = combineReducers(initialReducers)
    }
  }
}
const ConfigureStore = () => {
  // Const assignment.
  const _configuration = {
    'key': 'primary',
    'storage': AsyncStorage,
    'transforms': [
      /*
       * Create a transformer by passing the reducer key and configuration. Values
       * Shown below are the available configurations with default values
       */
      ExpireReducer('Account', {
        // (Required) Seconds after which store will be expired
        'expireSeconds': 1000 * 60 * 60 * 24 * 20,
        /*
         * (Optional) Use it if you don't want to manually set the time in the reducer i.e. at `persistedAtKey`
         * And want the store to  be automatically expired if the record is not updated in the `expireSeconds` time
         */
        'autoExpire': true
      })
    ],
    'debug': true,
    'writeFailHandler': error => throw error
  }

  // Create redux reducer manager.
  const _ReducerManager = CreateReducerManager({ Theme, System })

  // Preserve initial state for not-yet-loaded reducers
  const _PersistedReducer = persistReducer(_configuration, _ReducerManager.reduce)
  const _store = createStore(_PersistedReducer, compose(applyMiddleware(Thunk), reduxBatch, ReduxReset()))

  // Optional: Put the reducer manager on the store so it is easily accessible
  _store.Manager = _ReducerManager

  // Monkey patch store manager for adding middleware.
  const _nextDispatch = _store.dispatch
  _store.dispatch = action => _nextDispatch(action)

  // Update manager.
  Manager = { 'store': _store, 'persistedStore': persistStore(_store) }

  // Return persisted store.
  return Manager
}

/*
 * EXPORTS
 */
export default ConfigureStore
export { Manager }

Redux Provider

/*
 * IMPORTS
 */
import 'proxy-polyfill' // Npm: proxy polyfill library.
import 'intl' // Npm: internalization poly fill library.
import 'intl/locale-data/jsonp/en' // Npm: intl locale data.
import React from 'react' // Npm: react.js library.
import RNGeoCoding from 'react-native-geocoding' // Npm: react-native google places api.
import * as Sentry from '@sentry/react-native' // Npm: bug reporting platform.
import { AppRegistry } from 'react-native' // Npm: react native library.
import { Provider } from 'react-redux' // Npm: react-redux library.
import { gestureHandlerRootHOC as RNGesture } from 'react-native-gesture-handler' // Npm: react-native gesture handler.
import { PersistGate } from 'redux-persist/integration/react' // Npm: react persist library.

/*
 * COMPONENTS
 */
import App from 'app'
import Store from 'Store'

/*
 * OBJECTS
 */
const Index = () => {
// Const assignment.
  const StoreManager = Store()

  // Return component.
  return (
    <Provider store={StoreManager.store}>
      <PersistGate persistor={StoreManager.persistedStore}>
        <App />
      </PersistGate>
    </Provider>
  )
}

/*
 * REGISTER
 */
AppRegistry.registerComponent('App', () => RNGesture(Index))

Index.js

/*
 * IMPORTS
 */
import React from 'react' // Npm: react.js library.
import PropTypes from 'prop-types' // Npm: react proptypes library.
import ErrorBoundary from 'react-native-error-boundary' // Npm: react-native error boundary.
import Moment from 'moment' // Npm: time utility module.
import i18n from 'react-native-i18n' // Npm: multilingual support.
import _ from 'underscore' // Npm: underscore utility.
import { LogBox } from 'react-native' // Npm: react native library.
import { ThemeProvider } from 'styled-components/native' // Npm: styled components theme provider library.
import { connect } from 'react-redux' // Npm: react-redux library.
import { RelayEnvironmentProvider } from 'relay-hooks' // Npm: relay-hook library.
import { ApolloClient, ApolloProvider, InMemoryCache } from '@apollo/client' // Npm: apollo client library for second options for handling graphql.
import { setContext } from '@apollo/client/link/context' // Npm: apollo context provider library.
import { createUploadLink } from 'apollo-upload-client' // Npm: apollo upload polyfill library.

/*
 * COMPONENTS
 */
import Routes from 'routes'
import MenuItems from 'common/src/menuItems'
import Components from 'common/src/components'

/*
 * SIBLINGS
 */
import Router from './Router'

/*
 * PAGES
 */
import 'iffe'

/*
 * SIBLINGS
 */
import Error from './index.error'

/*
 * RELAY
 */
import Environment from '~relay.environment'

/*
 *
 * GLOBALS
 */
const __IP__ = '192.168.1.101:4000'

/*
 * LOGBOX
 */
LogBox.ignoreLogs(['Warning: ...', 'TypeError: ...'])

/*
 * OBJECTS
 */
const Index = ({ account, setting, theme, system }) => {
  // Hook assignment.
  const [showPinView, setShowPinView] = React.useState(false)

  // Object assignment.
  const _LanguageUpdate = () => {
    // Const assignment.
    const _deviceLanguage = 'en-US' === system.language ? 'hi-IN' : 'en-US'

    // Update device language.
    StoreManager.store.dispatch([{ 'type': 'SYSTEM_UPDATE', 'System': { 'language': _deviceLanguage } }])

    // Update System.
    return i18n.locale = _deviceLanguage
  }
  const _HttpLink = createUploadLink({ 'uri': `http://${__IP__}/` })
  const _AuthLink = setContext((__, { headers }) => ({
    'headers': {
      ...headers,
      'keep-alive': 'true',
      'l-authorization': account.authorization
    }
  }))
  const _apolloGlobalClient = new ApolloClient({
    'link': _AuthLink.concat(_HttpLink),
    'cache': new InMemoryCache()
  })

  // Event handler.
  React.useEffect(() => {
    // Const assignment.
    const _currentTime = Moment()
    const _oldTime = Moment(account.accessPinExpireAt)
    const _isPinRequired = setting.userAccessPinExpireIn < _currentTime.diff(_oldTime, setting.accessPinExpireInUnit) && account.isAccessPinRequired

    /*
     * Only Update changes if given account is logout
     * or changed or if setting is changed based on changes
     */
    if (_isPinRequired !== showPinView) setShowPinView(_isPinRequired)
  }, [account, setting])

  console.log('==================+>>>>>>>>>>>>>', account)

  // Return component.
  return (
    <RelayEnvironmentProvider environment={Environment({ 'ip': __IP__, 'env': false, account, 'Logout': () => {} })}>
      <ApolloProvider client={_apolloGlobalClient}>
        <ErrorBoundary FallbackComponent={Error}>
          <ThemeProvider theme={theme}>
            <Router
              fullName={account.fullName}
              profilePicture={account.profilePicture}
              components={[Components]}
              routes={[Routes]}
              menuItems={[MenuItems]}
              autoLoad={[
                'Account.IsActive',
                'Mobile.NumberOfAccount',
                'Setting.Get',
                'Device.Update',              ]}
              defaultLanguage={system && system.language === i18n.currentLocale() ? system.language : i18n.currentLocale()}
              onLanguageChangePress={_LanguageUpdate}
              referralComponentId={'Components.Referral'}
              ComponentNameDecorator={v => {
                /*
                 * Remove routes name from given
                 * component name.
                 */
                if (v && v.includes('Routes.')) v = (v.split('Routes.'))[1]

                // Return name.
                return v
              }}
              RenderAbove={() => 'Components.NavBar'}
              RenderBelow={() => 'Components.QuickMenu'}
              RenderBehind={() => 'Account.__Entry__'}
              Render={() => ({
                'ACCOUNT_DEFAULT': 'Default'
              })[account.activeAs]}
              RenderOver={() => _.isEmpty(account.authorization) ? 'Account.Register.WithMobileNumber' : showPinView ? 'Account.PinVerification' : void 0}
            />
          </ThemeProvider>
        </ErrorBoundary>
      </ApolloProvider>
    </RelayEnvironmentProvider>
  )
}

/*
 * PROPTYPES
 */
Index.propTypes = {
  'account': PropTypes.object.isRequired,
  'setting': PropTypes.object.isRequired,
  'theme': PropTypes.object.isRequired,
  'system': PropTypes.object.isRequired
}

/*
 * REDUX
 */
const _MapStateToProps = __state => ({
  'account': __state.Account?.present  <---- It should Referesh to new updates but no.
})

/*
 * EXPORTS
 */
export default connect(_MapStateToProps)(Index)

Account.Register.WithMobileNumber

/*
 * IMPORTS
 */
import React from 'react' // Npm: react library.
import PropTypes from 'prop-types' // Npm: Proptypes library.
import DeviceInfo from 'react-native-device-info' // Npm: react-native device information.
import _ from 'underscore' // Npm: utility module.
import { Dimensions } from 'react-native' // Npm: react-native library.
import { Easing, useAnimatedStyle, useSharedValue, withTiming } from 'react-native-reanimated' // Npm: react-native re designed animation library.
import { connect } from 'react-redux' // Npm: react redux library.
import { useMutation } from 'relay-hooks' // Npm: relay.js hooks library.
import { Directions, FlingGestureHandler, State } from 'react-native-gesture-handler' // Npm: react-native gesture library.

/*
 * PACKAGES
 */
import Container from 'reusecore/src/elements/Container'

/*
 * SIBLINGS
 */
import Welcome from './Welcome'
import PhoneNumber from './PhoneNumber'
import Otp from './Otp'

/*
 * STYLES
 */
import ContainerWrapper from './index.style'

/*
 * RELAY
 */
import AccountRegisterWithMobileNumberMutation, { Response as AccountRegisterWithMobileNumberMutationResponse } from './__mutation/AccountRegisterWithMobileNumberMutation'

/*
 * GLOBALS
 */
const _height = Dimensions.get('window').height

/*
 * OBJECTS
 */
const Index = ({
  AccountUpdate
}) => {
  // Animation assignment.
  const _screenHeightValue = useSharedValue(0)
  const _screenHeightStyle = useAnimatedStyle(() => ({
    'bottom': withTiming(0 === _screenHeightValue.value ? 0 : 1 === _screenHeightValue.value ? _height : _height * 2, {
      'duration': 1000,
      'easing': Easing.out(Easing.exp)
    })
  }))

  // Hook assignment.
  const [state, setState] = React.useState({ 'pinView': false })
  const [mobileNumber, setMobileNumber] = React.useState(void 0)
  const [otp, setOtp] = React.useState(void 0)
  const [otpIsInvalid, setOtpIsInvalid] = React.useState(false)
  const [hash, setHash] = React.useState(void 0)
  const [isPhoneNumberWorking, setIsPhoneNumberWorking] = React.useState(false)
  const [isOtpWorking, setIsOtpWorking] = React.useState(false)
  const [isInValidAccount, setIsInValidAccount] = React.useState(false)
  const [heading, setHeading] = React.useState(void 0)
  const _maxPhoneNumberLength = React.useRef(10)
  const _maxOtpLength = React.useRef(5)
  const [deviceUniqueId, setDeviceUniqueId] = React.useState(void 0)
  const [MutationAccountRegisterWithMobileNumber] = useMutation(AccountRegisterWithMobileNumberMutation, {
    'onCompleted': ({ AccountRegisterWithMobileNumber }) => AccountRegisterWithMobileNumberMutationResponse({
      'screenHeightValue': _screenHeightValue,
      mobileNumber,
      setHeading,
      setIsPhoneNumberWorking,
      setOtpIsInvalid,
      AccountUpdate,
      setIsOtpWorking,
      setIsInValidAccount
    }, AccountRegisterWithMobileNumber)
  })

  // Object assignment.
  const _Account = $options => MutationAccountRegisterWithMobileNumber({
    'variables': {
      'mobileNumber': `+91${mobileNumber}`,
      'otp': $options?.otp ? $options?.otp : $options?.retryOtp ? void 0 : otp,
      'otpHash': hash,
      'retryOtp': $options?.retryOtp ?? false,
      deviceUniqueId
    }
  })
  const _SwipeGesture = ({ nativeEvent }) => {
    /*
     * Swipe only works when previous swipe event
     * is done.
     */
    if (nativeEvent.oldState === State.ACTIVE) {
      // Update Animation.
      if (0 === _screenHeightValue.value) _screenHeightValue.value = 1
      if (1 === _screenHeightValue.value) _screenHeightValue.value = 0
      if (2 === _screenHeightValue.value) _screenHeightValue.value = 1

      /*
       * And mark PhoneNumber & Otp screen working
       * to false.
       */
      setIsPhoneNumberWorking(false)
      setIsOtpWorking(false)
      setState({ ...state, 'pinView': false })
    }

    // Return void.
    return void 0
  }

  // Event handler.
  React.useEffect(() => {
    // Async handler.
    const _async = async () => {
      // Const assignment.
      const _getDeviceUniqueId = await DeviceInfo.getUniqueId()

      /*
       * If getting imei caught exception
       * than report failure.
       */
      if (_getDeviceUniqueId instanceof Error) throw _getDeviceUniqueId

      // Set imei of given device.
      setDeviceUniqueId(_getDeviceUniqueId)
    } ;_async().catch(error => { throw error })
  }, [])

  // Return component.
  return (
    <Container noGutter fullWidth>
      <FlingGestureHandler numberOfPointers={1} direction={Directions.DOWN} onHandlerStateChange={_SwipeGesture}>
        <ContainerWrapper style={[_screenHeightStyle]}>
          <Welcome
            onEnterMobileNumberPress={() => _screenHeightValue.value = 1}
          />
          <PhoneNumber
            isInValidAccount={isInValidAccount}
            heading={heading}
            onChange={v => {
              // Reset invalidation.
              setHeading(void 0)
              setIsInValidAccount(false)

              // Set isPhoneNumber working to true.
              setIsPhoneNumberWorking(false)

              // Set mobile number.
              return setMobileNumber(v)
            }}
            isWorking={isPhoneNumberWorking}
            onSubmit={() => {
              // Const assignment.
              const _mobileNumberOfUser = mobileNumber

              /*
               * Only proceed if mobile number is entered
               * else report failure.
               */
              if (_.isEmpty(_mobileNumberOfUser) || (!_.isEmpty(_mobileNumberOfUser) && _maxPhoneNumberLength.current !== _mobileNumberOfUser.split('').length)) {
                // Reset invalidation.
                setHeading(void 0)
                setIsInValidAccount(true)

                // Set isPhoneNumber working to true.
                return setIsPhoneNumberWorking(false)
              }

              // Reset invalidation.
              setHeading(void 0)
              setIsInValidAccount(false)

              // Set isPhoneNumber working to true.
              setIsPhoneNumberWorking(true)

              // And call account object.
              return _Account({ 'retryOtp': true })
            }}
          />
          <Otp
            heading={heading}
            isWorking={isOtpWorking}
            isInvalid={otpIsInvalid}
            onGetHash={v => setHash(v)}
            onArrive={v => {
              // Update otp.
              setOtp(v)

              // Mark Otp is working.
              setIsOtpWorking(true)

              /*
               * Auto submit otp once otp is received
               * and mark isWork to true.
               */
              return _Account({ 'otp': v })
            }}
            onBlur={v => {
              // Update otp.
              setOtp(v)

              // Set isOtp working to true.
              setIsOtpWorking(true)

              // And call account object.
              return _Account({ 'otp': v })
            } }
            onReSend={() => {
              // Set isOtp working to true.
              setIsOtpWorking(true)

              // Resend otp.
              return _Account({ 'retryOtp': true })
            }}
            onChange={v => setOtp(v)}
            onSwipeGesture={_SwipeGesture}
            onSubmit={() => {
              // If otp is empty than report failure.
              if (_.isEmpty(otp) || (!_.isEmpty(otp) && _maxOtpLength.current !== otp.split('').length)) return setOtpIsInvalid(true)

              // Set isOtp working to true.
              setIsOtpWorking(true)

              // And call account object.
              return _Account()
            }}
          />
        </ContainerWrapper>
      </FlingGestureHandler>
    </Container>
  )
}

/*
 * PROPTYPES
 */
Index.propTypes = {
  'theme': PropTypes.object.isRequired,
  'AccountUpdate': PropTypes.func.isRequired

}
Index.child = [Welcome, PhoneNumber, Otp]
Index.app = { 'fullScreen': true }
Index.renderAbove = { 'isTopLight': true, 'isBottomLight': true }
Index.title = 'WithMobileNumber'
Index.hide = true
Index.defaultProps = {}

/*
 * REDUX
 */
const _MapStateToProps = __state => ({ 'theme': __state.Theme })
const _MapDispatchToProps = __dispatch => ({
  'AccountUpdate': v => __dispatch({ 'type': 'ACCOUNT_UPDATE', 'Account': v })
})

/*
 * EXPORTS
 */
export default connect(_MapStateToProps, _MapDispatchToProps)(Index)

Steps to Reproduce

Even i dont know how to reporduce trying from last 3 days removed and undo android folder and these files but nothing is working.

markerikson commented 3 years ago

In this case, posting code won't really help, and the problem statement isn't exactly clear.

I think what you're saying is that the state in the store doesn't get updated when you interact with the app?

Unfortunately, that's not enough information for us to provide a potential solution. At a minimum, we'd need you to provide an actual repository that demonstrates this problem when you build the app.

dotsinspace commented 3 years ago

Even i dont know how to reporduce trying from last 3 days removed and undo android folder and these files but nothing is working. switching back to dev build ( react-native run-android ) everything fine perfectly.

markerikson commented 3 years ago

Yeah, unfortunately this doesn't sound like anything we can really help with, then.

I'm going to go ahead and close the issue. If you do manage to come up with a repo that reproduces it, we might be able to take a look.

dotsinspace commented 3 years ago

Hey Marker just created repo for this issue : git@gitlab.com:rootandleaves/react-native-issue.git please review it and help me out to figure out possible solution of it.

Creating Dev apk works fine when you click on home button login view will toggle but in Release apk nothing will going to work.