import React, { PropTypes } from 'react'
我怎样才能看到'反应导出的所有功能? ?
我调查了react.js
内的文件node_modules/dist/react.js
但找不到像module.exports = PropTypes ;
这样的语句......
答案 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