The unique key warning should only happen in dev.
Jim committed
Jan 13, 2015 at 14:03 UTC
6b5b1b3f17922d7281cf99ff264272aefbd6133f
2 files changed
+18
-14
src/utils/ReactChildren.js
+9
-7
@@ -81,13 +81,15 @@ function mapSingleChildIntoContext(traverseContext, child, name, i) {
81
var mapResult = mapBookKeeping.mapResult;
82
83
var keyUnique = !mapResult.hasOwnProperty(name);
84
- warning(
85
- keyUnique,
86
- 'ReactChildren.map(...): Encountered two children with the same key, ' +
87
- '`%s`. Child keys must be unique; when two children share a key, only ' +
88
- 'the first child will be used.',
89
- name
90
- );
84
+ if (__DEV__) {
85
+ warning(
86
+ keyUnique,
87
+ 'ReactChildren.map(...): Encountered two children with the same key, ' +
88
+ '`%s`. Child keys must be unique; when two children share a key, only ' +
89
+ 'the first child will be used.',
90
+ name
91
+ );
92
+ }
93
94
if (keyUnique) {
95
var mappedChild =
src/utils/flattenChildren.js
+9
-7
@@ -23,13 +23,15 @@ function flattenSingleChildIntoContext(traverseContext, child, name) {
23
// We found a component instance.
24
var result = traverseContext;
25
var keyUnique = !result.hasOwnProperty(name);
26
- warning(
27
- keyUnique,
28
- 'flattenChildren(...): Encountered two children with the same key, ' +
29
- '`%s`. Child keys must be unique; when two children share a key, only ' +
30
- 'the first child will be used.',
31
- name
32
- );
26
+ if (__DEV__) {
27
+ warning(
28
+ keyUnique,
29
+ 'flattenChildren(...): Encountered two children with the same key, ' +
30
+ '`%s`. Child keys must be unique; when two children share a key, only ' +
31
+ 'the first child will be used.',
32
+ name
33
+ );
34
+ }
35
if (keyUnique && child != null) {
36
result[name] = child;
37
}