在构建 android 和 ios 应用程序时,未定义不是 ReactNative 中的对象(评估 'a.PropTypes.string')

Undefined is not an object(evaluating 'a.PropTypes.string') in ReactNative while building an android and ios app

那里有很多类似的问题,但是我的还是不一样,因为大多数问题都给出了解决方案,比如使用:

import PropTypes from 'prop-types';

作为一个单独的包而不是来自:

import React, { Component, PropTypes } from 'react';

自从我开始我的项目以来,我就已经在做这些了。尽管如此,我还是面临着同样的问题。 下面是我的代码中我使用 proptypes 的地方之一:

ListItem.propTypes = {
  imageUrl: PropTypes.number,
  itemTitle: PropTypes.string,
  careerText: PropTypes.string,
  distanceText: PropTypes.number,
  imageWidth: PropTypes.number,
  imageHeight: PropTypes.number,
  onPressButton: PropTypes.func,
  isSpecial: PropTypes.bool,
};

任何帮助将不胜感激,在此先感谢。

我在使用 react-native 0.50 版时遇到了一些问题。您可以尝试升级 react 和 react-native 版本。我认为这应该可以解决您的问题。