Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/addons/transitions/ReactCSSTransitionGroupChild.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ var CSSCore = require('CSSCore');
var ReactTransitionEvents = require('ReactTransitionEvents');

var onlyChild = require('onlyChild');
var warning = require('warning');

// We don't remove the element from the DOM until we receive an animationend or
// transitionend event. If the user screws up and forgets to add an animation
Expand All @@ -31,11 +32,13 @@ var noEventListener = null;

if (__DEV__) {
noEventListener = function() {
console.warn(
warning(
false,
'transition(): tried to perform an animation without ' +
'an animationend or transitionend event after timeout (' +
NO_EVENT_TIMEOUT + 'ms). You should either disable this ' +
'transition in JS or add a CSS animation/transition.'
'%sms). You should either disable this ' +
'transition in JS or add a CSS animation/transition.',
NO_EVENT_TIMEOUT
);
};
}
Expand Down
25 changes: 11 additions & 14 deletions src/browser/ui/ReactDOMComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ var escapeTextContentForBrowser = require('escapeTextContentForBrowser');
var invariant = require('invariant');
var isEventSupported = require('isEventSupported');
var keyOf = require('keyOf');
var monitorCodeUse = require('monitorCodeUse');
var warning = require('warning');

var deleteListener = ReactBrowserEventEmitter.deleteListener;
Expand Down Expand Up @@ -74,14 +73,13 @@ function assertValidProps(props) {
'Directly setting property `innerHTML` is not permitted. ' +
'For more information, lookup documentation on `dangerouslySetInnerHTML`.'
);
if (props.contentEditable && props.children != null) {
console.warn(
'A component is `contentEditable` and contains `children` managed by ' +
'React. It is now your responsibility to guarantee that none of ' +
'those nodes are unexpectedly modified or duplicated. This is ' +
'probably not intentional.'
);
}
warning(
!props.contentEditable || props.children == null,
'A component is `contentEditable` and contains `children` managed by ' +
'React. It is now your responsibility to guarantee that none of ' +
'those nodes are unexpectedly modified or duplicated. This is ' +
'probably not intentional.'
);
}
invariant(
props.style == null || typeof props.style === 'object',
Expand All @@ -95,11 +93,10 @@ function putListener(id, registrationName, listener, transaction) {
if (__DEV__) {
// IE8 has no API for event capturing and the `onScroll` event doesn't
// bubble.
if (registrationName === 'onScroll' &&
!isEventSupported('scroll', true)) {
monitorCodeUse('react_no_scroll_event');
console.warn('This browser doesn\'t support the `onScroll` event');
}
warning(
registrationName !== 'onScroll' || isEventSupported('scroll', true),
'This browser doesn\'t support the `onScroll` event'
);
}
var container = ReactMount.findReactContainerForID(id);
if (container) {
Expand Down
12 changes: 8 additions & 4 deletions src/browser/ui/ReactMount.js
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,8 @@ var ReactMount = {
var rootElementSibling = reactRootElement;
while (rootElementSibling) {
if (ReactMount.isRenderedByReact(rootElementSibling)) {
console.warn(
warning(
false,
'render(): Target node has markup rendered by React, but there ' +
'are unrelated nodes as well. This is most commonly caused by ' +
'white-space inserted around server-rendered markup.'
Expand Down Expand Up @@ -648,7 +649,8 @@ var ReactMount = {
// warning is when the container is empty.
rootElementsByReactRootID[reactRootID] = containerChild;
} else {
console.warn(
warning(
false,
'ReactMount: Root element has been removed from its original ' +
'container. New container:', rootElement.parentNode
);
Expand Down Expand Up @@ -828,15 +830,17 @@ var ReactMount = {
);

if (__DEV__) {
console.warn(
warning(
false,
'React attempted to reuse markup in a container but the ' +
'checksum was invalid. This generally means that you are ' +
'using server rendering and the markup generated on the ' +
'server was not what the client was expecting. React injected ' +
'new markup to compensate which works but you have lost many ' +
'of the benefits of server rendering. Instead, figure out ' +
'why the markup being generated is different on the client ' +
'or server:\n' + difference
'or server:\n%s',
difference
);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/browser/ui/__tests__/ReactDOMComponent-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ describe('ReactDOMComponent', function() {
ReactTestUtils.renderIntoDocument(<div onScroll={function(){}} />);
expect(console.warn.calls.length).toBe(1);
expect(console.warn.mostRecentCall.args[0]).toBe(
'This browser doesn\'t support the `onScroll` event'
'Warning: This browser doesn\'t support the `onScroll` event'
);
});
});
Expand Down
35 changes: 16 additions & 19 deletions src/classic/class/ReactClass.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ var assign = require('Object.assign');
var invariant = require('invariant');
var keyMirror = require('keyMirror');
var keyOf = require('keyOf');
var monitorCodeUse = require('monitorCodeUse');
var warning = require('warning');

var MIXINS_KEY = keyOf({mixins: null});
Expand Down Expand Up @@ -659,17 +658,19 @@ function bindAutoBindMethod(component, method) {
// ignore the value of "this" that the user is trying to use, so
// let's warn.
if (newThis !== component && newThis !== null) {
monitorCodeUse('react_bind_warning', { component: componentName });
console.warn(
warning(
false,
'bind(): React component methods may only be bound to the ' +
'component instance. See ' + componentName
'component instance. See %s',
componentName
);
} else if (!args.length) {
monitorCodeUse('react_bind_warning', { component: componentName });
console.warn(
warning(
false,
'bind(): You are binding a component method to the component. ' +
'React does this for you automatically in a high-performance ' +
'way, so you can safely remove this call. See ' + componentName
'way, so you can safely remove this call. See ',
componentName
);
return boundMethod;
}
Expand Down Expand Up @@ -874,18 +875,14 @@ var ReactClass = {
);

if (__DEV__) {
if (Constructor.prototype.componentShouldUpdate) {
monitorCodeUse(
'react_component_should_update_warning',
{ component: spec.displayName }
);
console.warn(
(spec.displayName || 'A component') + ' has a method called ' +
'componentShouldUpdate(). Did you mean shouldComponentUpdate()? ' +
'The name is phrased as a question because the function is ' +
'expected to return a value.'
);
}
warning(
!Constructor.prototype.componentShouldUpdate,
'%s has a method called ' +
'componentShouldUpdate(). Did you mean shouldComponentUpdate()? ' +
'The name is phrased as a question because the function is ' +
'expected to return a value.',
spec.displayName || 'A component'
);
}

// Reduce time spent doing lookups by setting these on the prototype.
Expand Down
4 changes: 2 additions & 2 deletions src/classic/class/__tests__/ReactClass-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ describe('ReactClass-spec', function() {
});
expect(console.warn.argsForCall.length).toBe(1);
expect(console.warn.argsForCall[0][0]).toBe(
'A component has a method called componentShouldUpdate(). Did you ' +
'Warning: A component has a method called componentShouldUpdate(). Did you ' +
'mean shouldComponentUpdate()? The name is phrased as a question ' +
'because the function is expected to return a value.'
);
Expand All @@ -185,7 +185,7 @@ describe('ReactClass-spec', function() {
});
expect(console.warn.argsForCall.length).toBe(2);
expect(console.warn.argsForCall[1][0]).toBe(
'NamedComponent has a method called componentShouldUpdate(). Did you ' +
'Warning: NamedComponent has a method called componentShouldUpdate(). Did you ' +
'mean shouldComponentUpdate()? The name is phrased as a question ' +
'because the function is expected to return a value.'
);
Expand Down
10 changes: 2 additions & 8 deletions src/classic/element/ReactElementValidator.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ var ReactCurrentOwner = require('ReactCurrentOwner');
var ReactNativeComponent = require('ReactNativeComponent');

var getIteratorFn = require('getIteratorFn');
var monitorCodeUse = require('monitorCodeUse');
var invariant = require('invariant');
var warning = require('warning');

Expand Down Expand Up @@ -157,22 +156,17 @@ function warnAndMonitorForKeyUse(warningID, message, element, parentType) {
// Usually the current owner is the offender, but if it accepts children as a
// property, it may be the creator of the child that's responsible for
// assigning it a key.
var childOwnerName = null;
if (element &&
element._owner &&
element._owner !== ReactCurrentOwner.current) {
// Name of the component that originally created this child.
childOwnerName = getName(element._owner);
var childOwnerName = getName(element._owner);

message += ` It was passed a child from ${childOwnerName}.`;
}

message += ' See http://fb.me/react-warning-keys for more information.';
monitorCodeUse(warningID, {
component: useName,
componentOwner: childOwnerName
});
console.warn(message);
warning(false, '%s', warningID + ': ' + message);
}

/**
Expand Down
13 changes: 6 additions & 7 deletions src/core/ReactCompositeComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -588,13 +588,12 @@ var ReactCompositeComponentMixin = {
inst.shouldComponentUpdate(nextProps, nextState, nextContext);

if (__DEV__) {
if (typeof shouldUpdate === 'undefined') {
console.warn(
(this.getName() || 'ReactCompositeComponent') +
'.shouldComponentUpdate(): Returned undefined instead of a ' +
'boolean value. Make sure to return true or false.'
);
}
warning(
typeof shouldUpdate !== 'undefined',
'%s.shouldComponentUpdate(): Returned undefined instead of a ' +
'boolean value. Make sure to return true or false.',
this.getName() || 'ReactCompositeComponent'
);
}

if (shouldUpdate) {
Expand Down
2 changes: 1 addition & 1 deletion src/core/__tests__/ReactCompositeComponent-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ describe('ReactCompositeComponent', function() {

expect(console.warn.argsForCall.length).toBe(1);
expect(console.warn.argsForCall[0][0]).toBe(
'Component.shouldComponentUpdate(): Returned undefined instead of a ' +
'Warning: Component.shouldComponentUpdate(): Returned undefined instead of a ' +
'boolean value. Make sure to return true or false.'
);
});
Expand Down