[React Native]不変の違反:アプリケーションは登録されていません
Invariant Violation
説明:これは、xxxがこのプロジェクトに登録されていないことを意味します
このエラーの根本的な原因はルートディレクトリです。/index.ios.js
AppRegistry.registerComponent( ‘プロジェクト名’、()=>…)
および./ios/projectname / appDelegate.m
RCTRootView * rootView = [[RCTRootViewalloc] initWithBundleURL:jsCodeLocation
moduleName:@ 'プロジェクト名' launchOptions:launchOptions]
または./android/app/src/main/java/com/projectname / MainActivity.java
mReactRootView.startReactApplication(mReactInstanceManager、 'プロジェクト名'、null)
一貫性がありません。
解決:
- ステップ1:対応するモジュール名を変更する
RCTRootView*rootView = [[RCTRootViewalloc]initWithBundleURL:jsCodeLocation
- ステップ2
./index.ios.js
プロジェクト名を変更する
AppRegistry.registerComponent('xxx', () => xxx)
- それでも上記の変更が機能しない場合は、
1. ReactNativeによって生成されたターミナルを閉じます
2.xcodeを閉じます
3.再コンパイルします
(これは、すべてをクリーンアップして再実行できるようにするためです。同時に、react nativeで一度に複数のプログラムが実行されている場合は、閉じる必要があり、実行できるのは1つだけです)