由'反应'导出的函数

时间:2017-12-13 11:39:08

标签: javascript reactjs react-native redux react-redux

import React, { PropTypes } from 'react'

我怎样才能看到'反应导出的所有功能? ?

我调查了react.js内的文件node_modules/dist/react.js但找不到像module.exports = PropTypes ;这样的语句......

1 个答案:

答案 0 :(得分:1)

我正在检查react(15.4.1)库的旧版本。

导出./lib/React

./lib/React.js文件有module.exports = React;

同一文件中的

React对象定义为:

var React = {

  // Modern

  Children: {
    map: ReactChildren.map,
    forEach: ReactChildren.forEach,
    count: ReactChildren.count,
    toArray: ReactChildren.toArray,
    only: onlyChild
  },

  Component: ReactComponent,
  PureComponent: ReactPureComponent,

  createElement: createElement,
  cloneElement: cloneElement,
  isValidElement: ReactElement.isValidElement,

  // Classic

  PropTypes: ReactPropTypes,
  createClass: ReactClass.createClass,
  createFactory: createFactory,
  createMixin: function (mixin) {
    // Currently a noop. Will be used to validate and trace mixins.
    return mixin;
  },

  // This looks DOM specific but these are actually isomorphic helpers
  // since they are just generating DOM strings.
  DOM: ReactDOMFactories,

  version: ReactVersion,

  // Deprecated hook for JSX spread, don't use this for anything.
  __spread: __spread
};

在这里,我可以看到它包含PropTypes属性,可以使用import {PropTypes} from 'react'导入。

注意:

  自从React以来,

React.PropTypes已迁移到另一个包中   V15.5。请改用prop-types库。

来源:https://reactjs.org/docs/typechecking-with-proptypes.html