2017-08-01 37 views
0

在我的原生反應項目中,我收到以下警告。反應本機警告 - 例如「PropTypes已被移動到一個單獨的包」

Warning: PropTypes has been moved to a separate package. Accessing React.PropTypes is no longer supported and will be removed completely in React 16. Use the prop-types package on npm instead. 

Warning: React.createClass is no longer supported. Use a plain JavaScript class instead. If you're not yet ready to migrate, create-react-class is available on npm as a drop-in replacement. 

Warning: View.propTypes has been deprecated and will be removed in a future version of ReactNative. Use ViewPropTypes instead. 

不過,我敢肯定,我還沒有在我的項目做到了這一點,並已經做了全局搜索,好像它們的實例是節點模塊文件夾中,特別是在模塊,我沒有安裝我自己。我應該如何繼續?我試圖按照文檔中的建議重新構建以下命令。

jscodeshift -t react-codemod/transforms/React-PropTypes-to-prop-types.js <path> 

當我嘗試它時,幾個節點模塊損壞,應用程序無法編譯。之後我不得不重新安裝npm模塊,所以我沒有取得任何進展。

回答

1

發生警告是因爲PropTypes被移動到單獨的包 - 'prop-types'。此外,React.createClass已棄用。

該警告發生在您的應用程序或您使用的軟件包中。

要在您的應用程序刪除它,請

import PropTypes from 'prop-types'; 

轉換React.createClass到ES6組件。

如果警告發生在您使用的軟件包中,請通過提出git問題來密切關注軟件包所有者。大多數軟件包已經做出了這一改變。所以,你應該升級這些軟件包。如果軟件包是最新的,並且錯誤仍然存​​在,請提出問題。

+0

有什麼方法可以準確找出這些警告發生的位置嗎?我已經完成了全球搜索,但仍不清楚該警告指的是什麼文件。 –

+0

當第三方dep不兼容時,你很不走運。讓他們更新。如果一個dep ...的瞬時dep可能是切換的時間。一段時間以來沒有被觸及的很多靜重。警告只針對'env ='development'',所以它不會影響你的構建。此外,反應原生16將仍然有一段時間。 –

+0

@DimitarChristoff謝謝! –

相關問題