javascript – React native Undefined不是对象(评估’_react3.default.PropType.shape’)
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了javascript – React native Undefined不是对象(评估’_react3.default.PropType.shape’),小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含2207字,纯文字阅读大概需要4分钟。
内容图文
我正在研究React-native因为这种情况我想为IOS和Android创建导航,实际上,我遇到了一个错误
错误:React native Undefined不是对象(评估’_react3.default.PropType.shape’)
我的发展环境
> OS:MACOS Sierra
> Clie:react-native-cli:2.0.1
> React-native版本:react-native:0.49.3
我遵循官方反应原生tutorial
App.js
import React, { Component } from 'react';
import {Platform, StyleSheet, Text, View} from 'react-native';
import Navigator from 'react-native-deprecated-custom-components';
import MyScene from './src/components/navigation/MyScene';
const instructions = Platform.select({
ios: 'IOS: Press Cmd+R to reload,\n' +
'Cmd+D or shake for dev menu',
android: 'Android : Double tap R on your keyboard to reload,\n' +
'Shake or press menu button for dev menu',
});
export default class App extends Component {
render() {
return (
<Navigator initialRoute={{ title: 'My Initial Scene', index: 0 }}
renderScene={(route, navigator) =>
<MyScene
title={route.title}
// Function to call when a new scene should be displayed
onForward={() => {
const nextIndex = route.index + 1;
navigator.push({
title: 'Scene ' + nextIndex,
index: nextIndex,
});
}}
// Function to call to go back to the previous scene
onBack={() => {
if (route.index > 0) {
navigator.pop();
}
}}
/>
}
/>
)
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF',
},
welcome: {
fontSize: 50,
textAlign: 'center',
margin: 10,
},
instructions: {
textAlign: 'center',
color: '#333333',
marginBottom: 5,
},
});
MyScene.js
import React, { Component, PropTypes } from 'react';
import { View, Text, TouchableHighlight } from 'react-native';
export default class MyScene extends Component {
render() {
return (
<View>
<Text>Current Scene: {this.props.title}</Text>
<TouchableHighlight onPress={this.props.onForward}>
<Text>Tap me to load the next scene</Text>
</TouchableHighlight>
<TouchableHighlight onPress={this.props.onBack}>
<Text>Tap me to go back</Text>
</TouchableHighlight>
</View>
)
}
}
MyScene.propTypes = {
title: PropTypes.string.isRequired,
onForward: PropTypes.func.isRequired,
onBack: PropTypes.func.isRequired,
};
解决方法:
检查你的反应版本,
如果版本是> 16然后propTypes在一个名为prop-types的新包中
见:https://www.npmjs.com/package/prop-types
内容总结
以上是互联网集市为您收集整理的javascript – React native Undefined不是对象(评估’_react3.default.PropType.shape’)全部内容,希望文章能够帮你解决javascript – React native Undefined不是对象(评估’_react3.default.PropType.shape’)所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。