2017-06-13 77 views
1

我得到這個PropTypes validators directly is not supported警告這些組件TreeViewObjectInspectorConnectedTreeNodeObjectRootLabelObjectPreview,但支持我不知道這些組件屬於哪個庫。PropTypes驗證不要直接從`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`. 

回答

1

在項目文件中使用搜索來查找這些組件所在的庫。下面是一些我發現使用谷歌搜索:

嘗試下載這些庫的最後版本,看看他們解決這些警告。如果沒有,您可以創建PR /問題,或者等待有人修復它。

順便說一句,在你的React應用程序的production build這些警告將消失。

0

由於使用prop-types軟件包的組件庫已更新,但您的React版本與其不兼容,您將不得不更新React至版本15.3.0或最新版本。請查詢here以獲取更多信息

1

即使我遇到了同樣的問題,但是兩者的反應和prop-types軟件包都是最新的。

我寫

visibility: PropTypes.bool() 

,而不是

visibility: PropTypes.bool 

我用的是PropTypes類型的功能,因此它被扔的錯誤。