React native Undefined不是对象(评估’_react3.default.PropType.shape’)
我正在学习React-native因为这个案例我想为IOS和Android创建导航,实际上,我遇到了一个错误
错误: React native Undefined不是对象(评估’_react3.default.PropType.shape’)
我的发展环境
- 操作系统:MACOS Sierra
- Clie:react-native-cli:2.0.1
- React-native版本:react-native:0.49.3
我遵循官方反应原生教程
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 ( { 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 ( Current Scene: {this.props.title} Tap me to load the next scene Tap me to go back ) } } 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
- 如何debuggingWKWebView中的JavaScript代码
- 使用StageWebView.loadString()在AIR for iOS上显示Google地图
- 如何从PhoneGap camera.getPicture获取File对象?
- iOS网络应用程序:禁用输入文本字段上的自动对焦
- Tooploox Hackathon:Timeploox,用于时间跟踪的Slack机器人
- Javascript – iPad的标签键检测与蓝牙键盘
- 如何为iPhone构buildReact Native App?
- 如何在Javascript中捕获文本选择更改的iOS Safari事件?
- cordova应用程序(iOS)中的iframe history.back()问题