当我运行expo start
时,收到的警告是:
Warning: componentWillReceiveProps has been renamed, and is not recommended for use.
...
* Rename componentWillReceiveProps to UNSAFE_componentWillReceiveProps to suppress this warning in non-strict mode. In React 17.x, only the UNSAFE_ name will work. To rename all deprecated lifecycles to their new names, you can run `npx react-codemod rename-unsafe-lifecycles` in your project source folder.
Please update the following components: SafeView, Transitioner
- node_modules/expo/build/environment/muteWarnings.fx.js:18:23 in warn
...
我知道这是一个警告,在生产模式下不会看到,但为了不丢失其他可能的警告,我想摆脱此警告。
我未使用componentWillReceiveProps
,但正在使用expo
的依赖项。
npx react-codemod rename-unsafe-lifecycles
仅检查我编写的代码,而不检查来自node_modules
的代码。Please update the following components: SafeView, Transitioner
不适用,因为它们不是来自我包括的组件,而是来自expo
及其依赖项,其中主要的是react-native
本身。作为解决方案,有什么方法可以通用的方式消除此警告?另外,有没有一种方法可以只删除SafeView
和Transitioner
组件(即react-native-safe-area-viewreact-navigation react-navigation-stack包)?
似乎(截至2020年3月2日)已在SDK 38中解决。
请参阅: