带有EXPO Reaction Native的应用程序剪辑找不到应用程序入口点模块名称?

本教程将介绍带有EXPO Reaction Native的应用程序剪辑找不到应用程序入口点模块名称?的处理方法,这篇教程是从别的地方看到的,然后加了一些国外程序员的疑问与解答,希望能对你有所帮助,好了,下面开始学习吧。

带有EXPO Reaction Native的应用程序剪辑找不到应用程序入口点模块名称? 教程 第1张

问题描述

我正在尝试将App Clip功能集成到在Reaction Native With EXPO中开发的应用程序中。

我声明我已经在没有世博会的Reaction Native项目中集成了App Clip功能,并且我没有遇到任何重大问题,而在世博会上我有一个无法解决的问题。

我在main.m文件中收到此错误:

不变违规:"ReactNativeTest"尚未注册。在以下情况下可能会发生这种情况:

    Metro(本地开发服务器)从错误的文件夹运行。检查Metro是否正在运行,停止它,然后在当前项目中重新启动它。

    由于错误,模块加载失败,AppRegistry.registerComponent未被调用。

我认为在这一点上问题与ViewController.m文件有关:

// moduleName corresponds to the appName used for the
// app entry point in "index.js"
RCTRootView *rootView = [[RCTRootView alloc]
initWithBundleURL:jsCodeLocation moduleName:@"ReactNativeTest"
initialProperties:nil launchOptions:nil];

在没有博览会的项目中,"index.js"中的应用程序入口点的modeName是

但在这种情况下它不起作用,您有解决方案吗?

推荐答案

好的,我自己找到了解决方案,如果有人需要,我按照以下步骤操作:

在index.appclip.js中,我将其修改为:

import { AppRegistry, View, Text } from 'react-native';
import { name as appName } from './app.json';
import React from 'react';

const AppClip = () => (
  <View style={{
 flex: 1,
 justifyContent: "center",
 alignItems: "center",
 backgroundColor: "#BFEFFF"
  }}>
 <Text style={{
fontSize: 26,
color: "#204080"
 }}>Hello React Native App Clip</Text>
  </View>
);

AppRegistry.registerComponent(appName, () => AppClip);

至此:

import { View, Text } from 'react-native';
import { registerRootComponent } from 'expo';
import React from 'react';

const AppClip = () => (
  <View style={{
 flex: 1,
 justifyContent: "center",
 alignItems: "center",
 backgroundColor: "#BFEFFF"
  }}>
 <Text style={{
fontSize: 26,
color: "#204080"
 }}>Hello React Native App Clip</Text>
  </View>
);

registerRootComponent(AppClip);

,并且&quot;index.js&quot;中的应用程序入口点的modeName是&quot;main&quot;,因此我修改了ViewController.m,如下所示:

// moduleName corresponds to the appName used for the
// app entry point in "index.js"
RCTRootView *rootView = [[RCTRootView alloc]
initWithBundleURL:jsCodeLocation moduleName:@"main"
initialProperties:nil launchOptions:nil];

好了关于带有EXPO Reaction Native的应用程序剪辑找不到应用程序入口点模块名称?的教程就到这里就结束了,希望趣模板源码网找到的这篇技术文章能帮助到大家,更多技术教程可以在站内搜索。