@samitouri / QOS-React-2 / commits / a27c6d1690

Always use a static message formats

These are the only places that seems to be including environment specific variables in the message format. By ensuring that they're static, we make it easier to group logs by format. I also ensure that I keep each addendum separate so that they can be filtered/grouped separately.

Sebastian Markbage committed Mar 2, 2015 at 13:00 UTC a27c6d1690a70a029ef09d087fb79cdff48583bb
2 files changed +16 -9
src/classic/element/ReactElementValidator.js
+10 -5
@@ -146,7 +146,7 @@ function warnAndMonitorForKeyUse(message, element, parentType) {
146 }
147 memoizer[useName] = true;
148
149 - message +=
149 + var parentOrOwnerAddendum =
150 ownerName ? ` Check the render method of ${ownerName}.` :
151 parentName ? ` Check the React.render call using <${parentName}>.` :
152 '';
@@ -154,17 +154,22 @@ function warnAndMonitorForKeyUse(message, element, parentType) {
154 // Usually the current owner is the offender, but if it accepts children as a
155 // property, it may be the creator of the child that's responsible for
156 // assigning it a key.
157 + var childOwnerAddendum = '';
158 if (element &&
159 element._owner &&
160 element._owner !== ReactCurrentOwner.current) {
161 // Name of the component that originally created this child.
162 var childOwnerName = getName(element._owner);
163
163 - message += ` It was passed a child from ${childOwnerName}.`;
164 + childOwnerAddendum = ` It was passed a child from ${childOwnerName}.`;
165 }
166
166 - message += ' See http://fb.me/react-warning-keys for more information.';
167 - warning(false, message);
167 + warning(
168 + false,
169 + message + '%s%s See http://fb.me/react-warning-keys for more information.',
170 + parentOrOwnerAddendum,
171 + childOwnerAddendum
172 + );
173 }
174
175 /**
@@ -248,7 +253,7 @@ function checkPropTypes(componentName, propTypes, props, location) {
253 loggedTypeFailures[error.message] = true;
254
255 var addendum = getDeclarationErrorAddendum(this);
251 - warning(false, 'Failed propType: ' + error.message + addendum);
256 + warning(false, 'Failed propType: %s%s', error.message, addendum);
257 }
258 }
259 }
src/core/ReactCompositeComponent.js
+6 -4
@@ -449,14 +449,16 @@ var ReactCompositeComponentMixin = {
449 // Preface gives us something to blacklist in warning module
450 warning(
451 false,
452 - 'Failed Composite propType: %s',
453 - error.message + addendum
452 + 'Failed Composite propType: %s%s',
453 + error.message,
454 + addendum
455 );
456 } else {
457 warning(
458 false,
458 - 'Failed Context Types: %s',
459 - error.message + addendum
459 + 'Failed Context Types: %s%s',
460 + error.message,
461 + addendum
462 );
463 }
464 }