Fix warning messages wording and access of displayName

This commit is contained in:
Ben Moss
2015-02-02 18:00:48 -05:00
parent 28f50c8a78
commit ba55716a2d
2 changed files with 11 additions and 9 deletions
+9 -7
View File
@@ -353,11 +353,12 @@ var ReactMount = {
// verify that that's the case.
warning(
ReactCurrentOwner.current == null,
'%s._renderNewRootComponent(): Render methods should be a pure ' +
'function of props and state; triggering nested component updates from ' +
'_renderNewRootComponent(): Render methods should be a pure function ' +
'of props and state; triggering nested component updates from ' +
'render is not allowed. If necessary, trigger nested updates in ' +
'componentDidUpdate.',
this.constructor.displayName || 'ReactCompositeComponent'
'componentDidUpdate. Check the render method of %s.',
ReactCurrentOwner.current && ReactCurrentOwner.current.getName() ||
'ReactCompositeComponent'
);
var componentInstance = instantiateReactComponent(nextComponent, null);
@@ -519,11 +520,12 @@ var ReactMount = {
// render but we still don't expect to be in a render call here.)
warning(
ReactCurrentOwner.current == null,
'%s.unmountComponentAtNode(): Render methods should be a pure function ' +
'unmountComponentAtNode(): Render methods should be a pure function ' +
'of props and state; triggering nested component updates from render ' +
'is not allowed. If necessary, trigger nested updates in ' +
'componentDidUpdate.',
this.constructor.displayName || 'ReactCompositeComponent'
'componentDidUpdate. Check the render method of %s.',
ReactCurrentOwner.current && ReactCurrentOwner.current.getName() ||
'ReactCompositeComponent'
);
invariant(
@@ -826,10 +826,10 @@ describe('ReactCompositeComponent', function() {
ReactTestUtils.renderIntoDocument(<Outer />);
expect(console.warn.argsForCall.length).toBe(1);
expect(console.warn.argsForCall[0][0]).toBe(
'Warning: ReactCompositeComponent._renderNewRootComponent(): Render methods should ' +
'Warning: _renderNewRootComponent(): Render methods should ' +
'be a pure function of props and state; triggering nested component ' +
'updates from render is not allowed. If necessary, trigger nested ' +
'updates in componentDidUpdate.'
'updates in componentDidUpdate. Check the render method of Outer.'
);
});