gpt4 book ai didi

ios - React native 错误 AppRegistry 未定义?

转载 作者:行者123 更新时间:2023-11-29 00:17:11 25 4
gpt4 key购买 nike

我一直在尝试通过 npm 将外部模块导入我的 React 应用程序,并在遵循 https://www.npmjs.com/package/react-native-material-design 之后我正在尝试融入 Material 设计。我还从“ react ”中导入了样式表等组件

我是 React Native 的新手,不明白为什么我在重新运行后会出现以下错误:

enter image description here

这是我所拥有的,我正在定义应用程序注册表,因为我的应用程序名称是 SkysReact:

import React, { Component } from 'react';
import { Button, Card } from 'react-native-material-design';
import {
StyleSheet,
Text,
View,
Animated,
Easing,
ScrollView,
RefreshControl
} from 'react-native';

//import AwesomeComponent from "./awesome.js";

//BODY
export default class SkysReact extends Component {
render() {
return (<View>
{this.test()}
</View>);
}

test() {
console.log("Hello World")
}

animate()
{
console.log("animate");
}
}

const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#000',
},
welcome: {
fontSize: 20,
textAlign: 'center',
margin: 10,
color: '#333333'
},
instructions: {
textAlign: 'center',
color: '#333333',
marginBottom: 5,
},
});

AppRegistry.registerComponent('SkysReact', () => SkysReact);

怎么了?它在我添加导入之前就在运行,无法理解哪里出了问题。

最佳答案

您忘记导入您的AppRegistry。将它添加到您的导入语句将清除您的问题

import {
AppRegistry,
StyleSheet,
Text,
View,
Animated,
Easing,
ScrollView,
RefreshControl
} from 'react-native';

关于ios - React native 错误 AppRegistry 未定义?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45061650/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com