@@ -2,6 +2,8 @@ import Immutable from 'immutable';
2
2
import React , { PureComponent , PropTypes } from 'react' ;
3
3
import { ListView , InteractionManager } from 'react-native' ;
4
4
5
+ const isImmutableIterable = Immutable . Iterable . isIterable ;
6
+
5
7
/**
6
8
* Return the keys from a set of data.
7
9
*
@@ -13,6 +15,10 @@ import { ListView, InteractionManager } from 'react-native';
13
15
* @returns {Array } An array of keys for the data.
14
16
*/
15
17
function getKeys ( immutableData ) {
18
+ if ( __DEV__ && ! isImmutableIterable ( immutableData ) ) {
19
+ console . warn ( `Can't get keys: Data is not Immutable: ${ JSON . stringify ( immutableData ) } ` ) ;
20
+ }
21
+
16
22
return immutableData . keySeq ( ) . toArray ( ) ;
17
23
}
18
24
@@ -23,10 +29,14 @@ function getKeys(immutableData) {
23
29
* - getRowIdentities({ section1: ['row1', 'row2'], section2: ['row1'] })
24
30
* will return [[0, 1], [0]].
25
31
*
26
- * @param immutableSectionData
32
+ * @param { Immutable.Iterable } immutableSectionData
27
33
* @returns {Array }
28
34
*/
29
35
function getRowIdentities ( immutableSectionData ) {
36
+ if ( __DEV__ && ! isImmutableIterable ( immutableSectionData ) ) {
37
+ console . warn ( `Can't get row identities: Data is not Immutable: ${ JSON . stringify ( immutableSectionData ) } ` ) ;
38
+ }
39
+
30
40
const sectionRowKeys = immutableSectionData . map ( getKeys ) ;
31
41
return sectionRowKeys . valueSeq ( ) . toArray ( ) ;
32
42
}
@@ -58,7 +68,7 @@ class ImmutableListView extends PureComponent {
58
68
immutableData : ( props , propName , componentName ) => {
59
69
// Note: It's not enough to simply validate PropTypes.instanceOf(Immutable.Iterable),
60
70
// because different imports of Immutable.js across files have different class prototypes.
61
- if ( ! Immutable . Iterable . isIterable ( props [ propName ] ) ) {
71
+ if ( ! isImmutableIterable ( props [ propName ] ) ) {
62
72
return new Error ( `Invalid prop ${ propName } supplied to ${ componentName } : Must be Immutable.Iterable.` ) ;
63
73
}
64
74
} ,
0 commit comments