undefined不是一个对象(评估'_react2.Proptypes.store')?

时间:2018-01-01 12:31:46

标签: react-native

我正在尝试建立出租车预订应用程序。从我得到错误 undefined is not an object (evaluating'_react2.Proptypes.store')。我在之前的问题中尝试了所有其他解决方案,但没有用。对此有任何帮助表示赞赏。

import React, { Component, PropTypes} from "react";
import { Router } from "react-native-router-flux";
import scenes from "../routes/scenes";



import { Provider } from "react-redux";

export default class AppContainer extends Component{
static propTypes =  {
        store: PropTypes.object.isRequired
}
render(){
    return(
        <Provider store = {this.props.store}>
            <Router scenes = {scenes} />
        </Provider>
        )
}
}

的package.json

{
"name": "TaxiApp",
"version": "0.0.7",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest"
},
"dependencies": {
"native-base": "^2.3.5",
"prop-types": "^15.6.0",
"react": "16.0.0",
"react-addons-update": "^15.6.2",
"react-native": "0.51.0",
"react-native-router-flux": "^4.0.0-beta.24",
"react-redux": "^5.0.6",
"redux": "^3.7.2",
"redux-thunk": "^2.2.0"
},
"devDependencies": {
"babel-jest": "22.0.4",
"babel-preset-react-native": "4.0.0",
"jest": "22.0.4",
"react-test-renderer": "16.0.0",
"redux-logger": "^3.0.6"
},
"jest": {
"preset": "react-native"
}
}

1 个答案:

答案 0 :(得分:0)

自从版本16.0.0向前反应之后,不能像在第一行那样从React本身获取prop类型。您需要执行以下操作;

  1. npm install prop-types --save
  2. 添加以下导入并从第一行中删除PropTypes: import PropTypes from 'prop-types';
  3. 在此之后,它应该像魅力一样。