我已经改变了我的index.js,因为我试图跟随这个图层:
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.发布于 2022-01-24 09:02:41
打开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 });
}如果您有此错误不变的违规:“main”尚未注册,您必须将'X‘替换为'main’。
另一个例子是:
如果您有此错误不变的违规:“应用程序”尚未注册,您必须替换'X‘的’应用‘。
https://stackoverflow.com/questions/66922050
复制相似问题