React Native-警告汇总
-
在使用
SectionList
的时候:
⚠️VirtualizedList: missing keys for items, make sure to specify a key property on each item or provide a custom keyExtractor.
解决方案:
_extraUniqueKey(item ,index){ return "index"+index+item; } <SectionList keyExtractor = {this._extraUniqueKey} />
-
在使用
FlatList
的时候:
⚠️VirtualizedList: missing keys for items, make sure to specify a key property on each item or provide a custom keyExtractor.
解决方案:
_extraUniqueKey(item ,index){ return "index"+index+item; } < FlatList keyExtractor = {this._extraUniqueKey} />
-
undefined is not an object(evaluating '_react3.default.PropTypes.shape'
1.png
解决方案:终端执行npm install --save https://github.com/facebookarchive/react-native-custom-components.git
-
[Invariant Violation: Element type is invalid: expected a string (for built-in components) or a class/function but got: object](https://stackoverflow.com/questions/34130539/uncaught-error-invariant-violation-element-type-is-invalid-expected-a-string)
Snip20171122_13.png
解决方案:.js
文件中使用import {Navigator} from 'react-native-deprecated-custom-components';
-
Navigator is deprecated and has been removed from this package. It can now be installed and import from ‘react-native-deprecated-custom-components’ instead of ‘react-native’
20170618160119886.png
解决方案:1. 通过npm安装相应的库,终端输入命令:npm i react-native-deprecated-custom-components --save 2. 在使用的JS文件中将Navigator引入进来:import {Navigator} from 'react-native-deprecated-custom-components';