简体   繁体   English

我的 React 版本有问题

[英]I have a problem with my version of React

I don't know much about React and I have to test an application made in React.我对 React 了解不多,我必须测试一个用 React 制作的应用程序。

My problem comes when I try to run the server with gulp nodemon , and I get a lot of errors.当我尝试使用gulp nodemon运行服务器时,我的问题出现了,并且出现了很多错误。 Apparently the application is built on an old version of React and doesn't recognize some libraries or modules;显然,该应用程序是基于旧版本的 React 构建的,并且无法识别某些库或模块; I have already solved several of them regarding prototypes or the way a ReactClass is created, but I found one regarding Bootstrap that I haven't been able to solve.我已经解决了其中几个关于原型或 ReactClass 创建方式的问题,但我发现了一个关于 Bootstrap 的问题,但我无法解决。

This is the error I get:这是我得到的错误:

bsStyle: _propTypes2['default'].oneOf(_styleMaps2['default'].STYLES),
                                ^
TypeError: Cannot read property 'oneOf' of undefined
    at Object.<anonymous> (/home/kevin/to_check/react-blog/node_modules/react-bootstrap/lib/BootstrapMixin.js:30:43)

This is the file I'm having the trouble with:这是我遇到问题的文件:

'use strict';

var _interopRequireDefault = require('babel-runtime/helpers/interop-require-default')['default'];
exports.__esModule = true;
var _react = require('react');
var _react2 = _interopRequireDefault(_react);
var _styleMaps = require('./styleMaps');
var _styleMaps2 = _interopRequireDefault(_styleMaps);
var _propTypes2 = require('prop-types');
var _reactPropTypesLibKeyOf = require('react-prop-types/lib/keyOf');
var _reactPropTypesLibKeyOf2 = _interopRequireDefault(_reactPropTypesLibKeyOf);

var BootstrapMixin = {
  propTypes: {
    /**
     * bootstrap className
     * @private
     */
    bsClass: _reactPropTypesLibKeyOf2['default'](_styleMaps2['default'].CLASSES),
    /**
     * Style variants
     * @type {("default"|"primary"|"success"|"info"|"warning"|"danger"|"link")}
     */
    bsStyle: _propTypes2['default'].oneOf(_styleMaps2['default'].STYLES),
    /**
     * Size variants
     * @type {("xsmall"|"small"|"medium"|"large"|"xs"|"sm"|"md"|"lg")}
     */
    bsSize: _reactPropTypesLibKeyOf2['default'](_styleMaps2['default'].SIZES)
  },

  getBsClassSet: function getBsClassSet() {
    var classes = {};

    var bsClass = this.props.bsClass && _styleMaps2['default'].CLASSES[this.props.bsClass];
    if (bsClass) {
      classes[bsClass] = true;

      var prefix = bsClass + '-';

      var bsSize = this.props.bsSize && _styleMaps2['default'].SIZES[this.props.bsSize];
      if (bsSize) {
        classes[prefix + bsSize] = true;
      }

      if (this.props.bsStyle) {
        if (_styleMaps2['default'].STYLES.indexOf(this.props.bsStyle) >= 0) {
          classes[prefix + this.props.bsStyle] = true;
        } else {
          classes[this.props.bsStyle] = true;
        }
      }
    }

    return classes;
  },

  prefixClass: function prefixClass(subClass) {
    return _styleMaps2['default'].CLASSES[this.props.bsClass] + '-' + subClass;
  }
};

exports['default'] = BootstrapMixin;
module.exports = exports['default'];

This is the package.json file that the application has:这是应用程序具有的 package.json 文件:

{
  "name": "React-Isomorphic-Blog",
  "version": "1.0.0",
  "description": "React Isomorphic Blog",
  "author": "Jonathan Rossi <jonathan.m.rossi@gmail.com>",
  "license": "MIT",
  "dependencies": {
    "alt": "^0.14.5",
    "babel": "^4.7.16",
    "body-parser": "^1.12.3",
    "cookie-parser": "^1.3.4",
    "create-react-class": "^15.6.3",
    "express": "^4.12.3",
    "express-session": "^1.10.4",
    "iso": "^4.0.2",
    "jade": "^1.9.2",
    "marked": "^1.1.0",
    "moment": "^2.10.2",
    "prop-types": "^15.7.2",
    "react": "^16.13.1",
    "react-bootstrap": "^0.26.2",
    "react-ga": "^2.1.2",
    "react-prop-types": "^0.4.0",
    "react-router": "^3.2.6",
    "superagent": "^5.2.2"
  },
  "devDependencies": {
    "browserify": "^16.5.1",
    "gulp": "^4.0.2",
    "gulp-clean": "^0.3.2",
    "gulp-concat": "^2.6.0",
    "gulp-minify-css": "^1.2.4",
    "gulp-nodemon": "^2.0.2",
    "gulp-print": "^2.0.1",
    "gulp-rename": "^1.2.2",
    "gulp-sass": "^4.1.0",
    "gulp-uglify": "^1.5.4",
    "nodemon": "^1.3.7",
    "reactify": "^1.1.0",
    "vinyl-buffer": "^1.0.0",
    "vinyl-source-stream": "^1.1.0"
  },
  "paths": {
    "app": "./src/client.js"
  },
  "dest": {
    "app": "bundle.js",
    "dist": "public/scripts/react"
  },
  "main": "bin/www.js",
  "scripts": {
    "start": "node --use_strict bin/www.js"
  }
}

I hope you can help me with that problem, I really couldn't find a solution.我希望你能帮助我解决这个问题,我真的找不到解决方案。 Thank you very much.非常感谢。

React.PropTypes has been extracted to it's own package since React v15.5.0.自 React v15.5.0 以来,React.PropTypes 已被提取到它自己的 package 中。

From this issue .从这个问题 The fix is to use the prop-types package instead解决方法是改用prop-types package

// bsStyle: _react2['default'].PropTypes.oneOf(_styleMaps2['default'].STYLES), // not this
bsStyle: _propTypes2['default'].oneOf(_styleMaps2['default'].STYLES) // do this after installing prop-types

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 升级 react-native 版本 0.70 时遇到一些问题 - I have some problem when I upgrade my react-native version 0.70 由于节点版本问题,无法安装 react-app 但我确实安装了最新版本 - Cannot install react-app because of a node version problem but I do have the last version installed 我在React中有一个重定向问题 - I have a problem with redirection in React 我应该解决一个计时器的 React 练习并通过按钮重置它。我在重置我的计时器时遇到问题 - I should solve a React exercise of a timer and reset it by a button.I have problem with resetting my timer 我尝试使用3反应导航版本运行我的drawerNavigation代码,但仍然说错误 - I have tried running my drawerNavigation code with 3 react navigation version but still says error 在开始新的反应项目时,我遇到了这个问题 - On start new react project I have this problem 我在安装 webpack 时遇到问题 - I have problem with install webpack react 我对 React 的 ToDoList 项目有一些问题 - I have some problem with ToDoList project by React 我对反应导航身份验证流程有疑问 - I have a problem with react navigation auth flow 我在使用 ckeditor 上传图片时遇到问题 - I have a problem with uploading my images with ckeditor
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM