Only monitor components that are likely stateful (inputs and composites)
Jim committed
Feb 12, 2015 at 14:25 UTC
f18dfdc00d3e0d14ce9d644e43be8d367ca25638
1 file changed
+20
-13
src/core/shouldUpdateReactComponent.js
+20
-13
@@ -57,19 +57,26 @@ function shouldUpdateReactComponent(prevElement, nextElement) {
57
nextElement.type.displayName != null) {
58
nextDisplayName = nextElement.type.displayName;
59
}
60
- warning(
61
- false,
62
- '<%s /> is being rendered by both %s and %s using the same key ' +
63
- '(%s) in the same place. Currently, this means that they ' +
64
- 'don\'t preserve state. This behavior should be very rare ' +
65
- 'so we\'re considering deprecating it. Please contact the ' +
66
- 'React team and explain your use case so that we can take that ' +
67
- 'into consideration.',
68
- nextDisplayName || 'Unknown Component',
69
- prevName || '[Unknown]',
70
- nextName || '[Unknown]',
71
- prevElement.key
72
- );
60
+ if (nextElement.type != null && typeof nextElement.type === 'string') {
61
+ nextDisplayName = nextElement.type;
62
+ }
63
+ if (typeof nextElement.type !== 'string' ||
64
+ nextElement.type === 'input' ||
65
+ nextElement.type === 'textarea') {
66
+ warning(
67
+ false,
68
+ '<%s /> is being rendered by both %s and %s using the same key ' +
69
+ '(%s) in the same place. Currently, this means that they ' +
70
+ 'don\'t preserve state. This behavior should be very rare ' +
71
+ 'so we\'re considering deprecating it. Please contact the ' +
72
+ 'React team and explain your use case so that we can take that ' +
73
+ 'into consideration.',
74
+ nextDisplayName || 'Unknown Component',
75
+ prevName || '[Unknown]',
76
+ nextName || '[Unknown]',
77
+ prevElement.key
78
+ );
79
+ }
80
}
81
}
82
return ownersMatch;