我收到PropTypes validators directly is not supported
,TreeView
,ObjectInspector
,ConnectedTreeNode
,ObjectRootLabel
这些组件的ObjectPreview
警告,但我不知道不知道这些组件属于哪个库。
如何摆脱这些警告?
Warning: Failed Context Types: Calling PropTypes validators directly is not supported by the `prop-types` package. Use `PropTypes.checkPropTypes()` to call them. Check the render method of `TreeView`.
Warning: Failed Context Types: Calling PropTypes validators directly is not supported by the `prop-types` package. Use `PropTypes.checkPropTypes()` to call them. Check the render method of `ObjectInspector`.
Warning: Failed Context Types: Calling PropTypes validators directly is not supported by the `prop-types` package. Use `PropTypes.checkPropTypes()` to call them. Check the render method of `ConnectedTreeNode`.
Warning: Failed Context Types: Calling PropTypes validators directly is not supported by the `prop-types` package. Use `PropTypes.checkPropTypes()` to call them. Check the render method of `ObjectRootLabel`.
Warning: Failed Context Types: Calling PropTypes validators directly is not supported by the `prop-types` package. Use `PropTypes.checkPropTypes()` to call them. Check the render method of `ObjectPreview`.
答案 0 :(得分:6)
即使我遇到了同样的问题,但反应和道具类型包都是最新的。
我写过
visibility: PropTypes.bool()
而不是
visibility: PropTypes.bool
我使用PropTypes类型作为函数,因此抛出错误。
答案 1 :(得分:1)
在项目文件中使用搜索来查找这些组件所在的库。以下是我使用Google搜索找到的一些内容:
TreeView
- react-treeview
ObjectInspector
- react-object-inspector
ObjectRootLabel
- react-inspector
尝试下载这些库的最新版本,看看他们是否修复了这些警告。如果没有,您可以创建PR /问题,或者等待某人修复它。
顺便说一句,在您的React应用的production build中,这些警告会消失。
答案 2 :(得分:1)
您收到此错误是因为使用prop-types包的组件库已更新,但您的React版本与其不兼容,您必须将15.3.0
更新为版本{{1}或最新版本。查看here了解详情