receiving Invariant Violation: Failed to call into JavaScript module method AppRegistry.runApplication(). after implementing redux into my app

huangapple go评论69阅读模式
英文:

receiving Invariant Violation: Failed to call into JavaScript module method AppRegistry.runApplication(). after implementing redux into my app

问题

收到这个错误。不变违例:

无法调用 JavaScript 模块方法
AppRegistry.runApplication()。模块尚未注册为
可调用。已注册可调用的 JavaScript 模块(n = 11):Systrace、
JSTimers、HeapCapture、SamplingProfiler、RCTLog、
RCTDeviceEventEmitter、RCTNativeAppEventEmitter、
GlobalPerformanceLogger、JSDevSupportModule、HMRClient、
RCTEventEmitter。

错误的一个常见原因是应用程序入口文件路径不正确。当 JS 捆绑包损坏或在加载 React Native 时出现早期初始化错误时,也会发生这种情况。
在实施 Redux 后出现了这个错误。Redux 正常工作,没有进行任何更改,突然之间我运行应用程序就出现了这个错误。

import {createStackNavigator} from '@react-navigation/stack';
import Home from './Screens/Home';
import PrEnteryScreen from './Screens/PrEnteryScreen';
import LogBookScreen from './Screens/LogBookScreen';
import AuthScreen from './Screens/AuthScreen';
import SelectExerciseModal from './Screens/SelectExerciseModal';
import RegisterModalScreen from './Screens/RegisterModalScreen';
import ExerciseInformationScreen from './Screens/ExerciseInformation';
import {AppRegistry} from 'react-native';

const MainStack = createStackNavigator();

const App = () => {
  return (
    <NavigationContainer>
      <MainStack.Navigator
        screenOptions={{ headerShown: false }}
        initialRouteName='AuthScreen'
      >
        <MainStack.Group>
          <MainStack.Screen name="AuthScreen" component={AuthScreen} />
          <MainStack.Screen name="Home" component={Home} />
          <MainStack.Screen name="PrEnteryScreen" component={PrEnteryScreen} />
          <MainStack.Screen name="LogBookScreen" component={LogBookScreen} />
          <MainStack.Screen
            name="ExerciseInformationScreen"
            component={ExerciseInformationScreen}
          />
        </MainStack.Group>
        <MainStack.Group screenOptions={{ presentation: 'modal' }}>
          <MainStack.Screen name="RegisterModalScreen" component={RegisterModalScreen} />
          <MainStack.Screen name="SelectExerciseModal" component={SelectExerciseModal} />
        </MainStack.Group>
      </MainStack.Navigator>
    </NavigationContainer>
  );
}

AppRegistry.registerComponent('PrApp', () => App);

export default App;

我添加了 AppRegistry.registerComponent('PrApp', () => App); 来尝试解决问题,但它不起作用。当我从实施 Redux 之前重新启动应用程序时,应用程序可以正常工作。

英文:

Receiving this error. Invariant Violation:

> Failed to call into JavaScript module method
> AppRegistry.runApplication(). Module has not been registered as
> callable. Registered callable JavaScript modules (n = 11): Systrace,
> JSTimers, HeapCapture, SamplingProfiler, RCTLog,
> RCTDeviceEventEmitter, RCTNativeAppEventEmitter,
> GlobalPerformanceLogger, JSDevSupportModule, HMRClient,
> RCTEventEmitter.

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.
This error came about after implementing redux. Redux was working, nothing was changed and then all the sudden I ran the app and this error appeared.

import {createStackNavigator } from &#39;@react-navigation/stack&#39;;
import Home from &#39;./Screens/Home&#39;;
import PrEnteryScreen from &#39;./Screens/PrEnteryScreen&#39;
import LogBookScreen from &#39;./Screens/LogBookScreen&#39;;
import AuthScreen from &#39;./Screens/AuthScreen&#39;;
import SelectExerciseModal from &#39;./Screens/SelectExerciseModal&#39;;
import RegisterModalScreen from &#39;./Screens/RegisterModalScreen&#39;;
import ExerciseInformationScreen from &#39;./Screens/ExerciseInformation&#39;;
import { AppRegistry} from &#39;react-native&#39;;

const MainStack = createStackNavigator();

const App = () =&gt; {
  return (
    &lt;NavigationContainer 
    &gt; 
      &lt;MainStack.Navigator
        screenOptions={{headerShown: false}}
        initialRouteName=&#39;AuthScreen&#39;
        &gt; 
          &lt;MainStack.Group&gt;
        
          &lt;MainStack.Screen name = &quot;AuthScreen&quot; component={AuthScreen}/&gt;        
            &lt;MainStack.Screen name = &quot;Home&quot; component={Home}/&gt;        
            &lt;MainStack.Screen name = &quot;PrEnteryScreen&quot; component = {PrEnteryScreen}/&gt;
            &lt;MainStack.Screen name = &quot;LogBookScreen&quot; component={LogBookScreen}/&gt;
            &lt;MainStack.Screen name = &quot;ExerciseInformationScreen&quot; component={ExerciseInformationScreen}/&gt;
          &lt;/MainStack.Group&gt;
          &lt;MainStack.Group screenOptions={{presentation: &#39;modal&#39;}}&gt;
          &lt;MainStack.Screen name =&quot;RegisterModalScreen&quot; component={RegisterModalScreen}/&gt;
            &lt;MainStack.Screen name =&quot;SelectExerciseModal&quot; component={SelectExerciseModal} /&gt;
          &lt;/MainStack.Group&gt;
      &lt;/MainStack.Navigator&gt;
    &lt;/NavigationContainer&gt;
  );
}

AppRegistry.registerComponent(&#39;PrApp&#39;, () =&gt; App);


export default App;

I added AppRegistry.registerComponent(&#39;PrApp&#39;, () =&gt; App); to try and solve the problem but it doesn't work. When I restart from before implementing redux the app works.

答案1

得分: 1

在最新的React Native版本(大于0.70)中,有许多变化,似乎有一些包不受支持。只需将React Native降级到>0.69,直到他们修复它。

英文:

In the latest react native version (greater than 0.70). there are many changes and it seems some packages are not supported. just downgrade react native to &gt;0.69 until they fix it .

huangapple
  • 本文由 发表于 2023年3月7日 02:53:27
  • 转载请务必保留本文链接:https://go.coder-hub.com/75654735.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定