如何解决带有 EXPO React Native 的 App Clip 未找到应用入口点模块名称?
我正在尝试将 App Clip 功能集成到我使用 EXPO React Native 开发的应用程序中。
我声明我已经在没有 EXPO 的 React Native 项目中集成了 App Clip 功能,并且我没有遇到任何重大问题,而在使用 expo 时我遇到了我无法解决的问题。
我在 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];
在没有 EXPO 的项目中,“index.js”中应用入口点的 moduleName 是这个
但在这种情况下它不起作用,您有解决方案吗?
解决方法
好的,我自己找到了解决方案,如果有人需要,我按照以下步骤操作:
在 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,color: "#204080"
}}>Hello React Native App Clip</Text>
</View>
);
registerRootComponent(AppClip);
并且“index.js”中应用程序入口点的moduleName是“main”,所以我像这样修改了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];
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。