有没有人像我一样,看到Warning特别难受,跟吃了苍蝇一样,如果是自己写的代码中有Warning我肯定想尽办法处理掉。但是有的时候是自己引用的一些组件中的Warning天天看到就难受了。解决办法跟大家分享一下。
版本
"react": "16.13.1",
"react-native": "0.63.2",
比如说,我的警告信息如下:
[Thu Sep 17 2020 16:40:46.170] WARN Warning: componentWillReceiveProps has been renamed, and is not recommended for use. See https://fb.me/react-unsafe-component-lifecycles for details.
* Move data fetching code or side effects to componentDidUpdate. * If you're updating state whenever props change, refactor your code to use memoization techniques or move it to static getDerivedStateFromProps. Learn more at: https://fb.me/react-derived-state * 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: %s Popover
import {LogBox} from 'react-native';
LogBox.ignoreLogs(['Warning: componentWillReceiveProps has been renamed']);
这下整个世界都清净了,好舒服。眼不见为净。