不变冲突:"main"尚未注册。如果出现以下情况,则可能会发生这种情况: * Metro (本地开发服务器)从错误的文件夹运行



我已经把我的index.js改成了这个,因为我试图遵循这个turorial:

https://www.youtube.com/watch?v=6soHPnHxHxI

import { registerRootComponent } from 'expo';
import React from "react";
import { AppRegistry } from "react-native";
import App from "./App";
import { name as appName } from "./app.json";
import { Provider } from "react-redux";
import { Provider as PaperProvider } from "react-native-paper"
import store from "./store";
import 'react-native-gesture-handler';
const AppRedux = () => {
<Provider {...{store}}>
<PaperProvider>
<App></App>
</PaperProvider>
</Provider>
}
// registerRootComponent calls AppRegistry.registerComponent('main', () => App);
// It also ensures that whether you load the app in the Expo client or in a native build,
// the environment is set up appropriately
//AppRegistry.registerComponent(appName, () => AppRedux);

// registerRootComponent calls AppRegistry.registerComponent('main', () => App);
// It also ensures that whether you load the app in the Expo client or in a native build,
// the environment is set up appropriately
registerRootComponent(AppRedux);

但我一直收到这个错误:

Invariant Violation: "main" has not been registered. This can happen if: * Metro (the local dev server) is run from the wrong folder.

打开index.js,文件的内容应该是这样的:

import { AppRegistry, Platform } from 'react-native';
import App from './App';
AppRegistry.registerComponent('X', () => App);
if (Platform.OS === 'web') {
const rootTag = document.getElementById('root') || document.getElementById('X');
AppRegistry.runApplication('X', { rootTag });
}

如果您有此错误,Invariant Violation:"main"尚未注册,您必须将"X"替换为"main"。

另一个例子:

如果您出现以下错误:"应用程序"尚未注册,则必须将"X"替换为"app"。

相关内容

  • 没有找到相关文章

最新更新