React-Native - undefined不是对象(“evaluation _react3.default.PropTypes.shape”)

时间:2017-10-15 18:19:14

标签: javascript android react-native

ERROR:

if($_FILES['avatar']['name'] == ""){
     $error[] = "Please Select a Picture!";
}

参见: http://rationalappdev.com/react-native-list-app-complete-how-to-guide/

App.js:

undefined is not an object (“evaluating _react3.default.PropTypes.shape”)
...
<unknown>
App.js 15
...

的package.json

import React, { Component } from 'react';

import {
  Platform,
  StyleSheet,
  Text,
  View
} from 'react-native';

import NavigationExperimental from 'react-native-deprecated-custom-components';

const instructions = Platform.select({
  ios: 'Press Cmd+R to reload,\n' +
    'Cmd+D or shake for dev menu',
  android: 'Double tap R on your keyboard to reload,\n' +
    'Shake or press menu button for dev menu',
});

const RouteMapper = (route, navigationOperations, onComponentRef) => {
  if (route.name === 'list') {
    return (
      // TODO: Add List component
      <Text>The list is going to be here</Text>
    );
  } else if (route.name === 'movie') {
    // TODO: Add Movie component for a movie detail screen
  }
};

export default class App extends Component<{}> {
  render() {
    return (
      <NavigationExperimental.Navigator
        // Default to list route
        initialRoute={{name: 'list'}}
        // Use FloatFromBottom transition between screens
        configureScene={(route, routeStack) => NavigationExperimental.Navigator.SceneConfigs.FloatFromBottom}
        // Pass a route mapper functions
        renderScene={RouteMapper}
      />
    );
  }
}

有什么想法吗?感谢

更新

安装{ "version": "0.0.1", "private": true, "scripts": { "start": "node node_modules/react-native/local-cli/cli.js start", "test": "jest" }, "dependencies": { "react": "16.0.0-beta.5", "react-native": "0.49.3", "react-native-deprecated-custom-components": "^0.1.1" }, "devDependencies": { "babel-jest": "21.2.0", "babel-preset-react-native": "4.0.0", "jest": "21.2.1", "react-test-renderer": "16.0.0-beta.5" }, "jest": { "preset": "react-native" } }

仍无法正常工作

enter image description here

1 个答案:

答案 0 :(得分:1)

PropTypes已被移出反应并进入其自己的组件: https://www.npmjs.com/package/prop-types

根据自述文件,他们建议在 package.json

中的依赖块中添加 prop-types
npm install --save prop-types

然后使用它:

import PropTypes from 'prop-types'; // ES6
var PropTypes = require('prop-types'); // ES5 with npm