Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redux Store throws error: "TypeError: undefined is not a function, js engine: hermes" #31210

Open
EmaProv opened this issue Mar 22, 2021 · 15 comments

Comments

@EmaProv
Copy link

EmaProv commented Mar 22, 2021

Start implementing Redux on my react native app cause me some troubles. After adding the redux store.js file, the console throws me this error:

 ERROR  TypeError: undefined is not a function, js engine: hermes
 ERROR  Invariant Violation: Module AppRegistry is not a registered callable module (calling runApplication). A frequent cause of the error is that the application entry file path is incorrect.
      This can also happen when the JS bundle is corrupt or there is an early initialization error when loading React Native., js engine: hermes
 ERROR  Invariant Violation: Module AppRegistry is not a registered callable module (calling runApplication). A frequent cause of the error is that the application entry file path is incorrect.
      This can also happen when the JS bundle is corrupt or there is an early initialization error when loading React Native., js engine: hermes

I really can't understand why it gives me this, someone could help me?

Here is my Store:

import {createStore, applyMiddleware, compose} from 'redux';
import {thunk} from 'redux-thunk';
import rootReducer from './src/reducers';

const initialState = {};

const middleware = [thunk];

const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;

const store = createStore(
  rootReducer,
  initialState,
  composeEnhancers(
    applyMiddleware(...middleware),
  ),
);

export default store;

And here is my App.js:

import React from 'react';
import {NavigationContainer} from '@react-navigation/native';

import DrawerNavigator from './src/routes/DreawerNavigator';

import {Provider} from 'react-redux';
import store from './store';

export default function App() {
  return (
    <Provider store={store}>
      <NavigationContainer>
        <DrawerNavigator />
      </NavigationContainer>
    </Provider>
  );
}

React Native version:

System:
    OS: Windows 10 10.0.19042
    CPU: (4) x64 Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz
    Memory: 1.35 GB / 7.91 GB
  Binaries:
    Node: 14.16.0 - C:\Program Files\nodejs\node.EXE
    Yarn: Not Found
    npm: 6.14.11 - C:\Program Files\nodejs\npm.CMD
    Watchman: Not Found
  SDKs:
    Android SDK:
      API Levels: 29, 30
      Build Tools: 28.0.3, 29.0.2, 30.0.3
      System Images: android-29 | Automotive with Play Store Intel x86 Atom, android-29 | Android TV Intel x86 Atom, android-29 | Intel x86 Atom, android-29 | Intel x86 Atom_64, android-29 | Google APIs Intel x86 Atom, android-29 | Google APIs Intel x86 Atom_64, android-29 | Google Play Intel x86 Atom, android-29 | Google Play Intel x86 Atom_64, android-30 | Google APIs Intel x86 Atom
      Android NDK: Not Found
    Windows SDK: Not Found
  IDEs:
    Android Studio: Version  4.1.0.0 AI-201.8743.12.41.7042882
    Visual Studio: Not Found
  Languages:
    Java: Not Found
  npmPackages:
    @react-native-community/cli: Not Found
    react: 16.13.1 => 16.13.1
    react-native: ^0.64.0 => 0.64.0
    react-native-windows: Not Found
  npmGlobalPackages:
    *react-native*: Not Found

package.json

{
  "name": "fastbook_app",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "android": "react-native run-android",
    "ios": "react-native run-ios",
    "start": "react-native start",
    "test": "jest",
    "lint": "eslint ."
  },
  "dependencies": {
    "@react-native-community/masked-view": "^0.1.10",
    "@react-navigation/drawer": "^5.12.4",
    "@react-navigation/native": "^5.9.3",
    "@react-navigation/stack": "^5.14.3",
    "react": "16.13.1",
    "react-native": "^0.64.0",
    "react-native-datepicker": "^1.7.2",
    "react-native-gesture-handler": "^1.10.3",
    "react-native-reanimated": "^2.0.0",
    "react-native-safe-area-context": "^3.2.0",
    "react-native-screens": "^2.18.1",
    "react-native-vector-icons": "^8.1.0",
    "react-redux": "^7.2.2",
    "redux": "^4.0.5",
    "redux-thunk": "^2.3.0"
  },
  "devDependencies": {
    "@babel/core": "^7.13.10",
    "@babel/runtime": "^7.13.10",
    "@react-native-community/eslint-config": "^1.1.0",
    "babel-jest": "^25.1.0",
    "eslint": "^6.5.1",
    "jest": "^25.1.0",
    "metro-react-native-babel-preset": "^0.59.0",
    "react-test-renderer": "16.13.1"
  },
  "jest": {
    "preset": "react-native"
  }
}

@faziloub
Copy link

Same Issue

@EmaProv
Copy link
Author

EmaProv commented Apr 1, 2021

any suggestions??

@FelipeSSantos1
Copy link

What is the version of your redux-thunk? if it's "^2.3.0" try to replace this import { thunk } from 'redux-thunk' with this import thunk from 'redux-thunk'

@wmonecke
Copy link

wmonecke commented May 8, 2021

Same problem! For me it's working in dev but not in release. Very weird...

@tthuwng
Copy link

tthuwng commented Jul 6, 2021

You can manually add the 0.7.0 version of the Hermes Engine that support Proxies and React Native 0.64.x

yarn add hermes-engine@0.7.0
cd android && ./gradlew clean

@RobberJJ
Copy link

RobberJJ commented Jul 1, 2022

Same Issue

@The-Lone-Druid
Copy link

did anyone find solution?

@erencsknn
Copy link

maybe fix as import rootReducers

@LouisMuriuki
Copy link

same issue here,i updated my dependecies now am facing the same error

@siemya
Copy link

siemya commented Jun 8, 2023

same issue

@shujer
Copy link

shujer commented Aug 10, 2023

same issue, any solution for this? --> fixed by add polyfill

import getOwnPropertyDescriptors from 'get-own-property-descriptors-polyfill' 
if (!Object.getOwnPropertyDescriptors) {   Object.getOwnPropertyDescriptors = getOwnPropertyDescriptors }

@bokmark
Copy link

bokmark commented Dec 7, 2023

same issue, any solution for this?

@KamranZafar19
Copy link

What is the version of your redux-thunk? if it's "^2.3.0" try to replace this import { thunk } from 'redux-thunk' with this import thunk from 'redux-thunk'

yes it's working thanku

@daruNBC
Copy link

daruNBC commented Jan 21, 2024

What is the version of your redux-thunk? if it's "^2.3.0" try to replace this import { thunk } from 'redux-thunk' with this import thunk from 'redux-thunk'

the inverse worked for me

@ricardogk3
Copy link

You resolved the issue by adding curly braces to the import statement: import { thunk } from 'redux-thunk';. This change was necessary because redux-thunk provides named exports, and when importing a specific export, the use of curly braces is required in JavaScript.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests