Add displayName to nested render warnings [#1726]

This commit is contained in:
Ben Moss
2015-01-26 14:14:36 -05:00
parent 4486a17c24
commit 28f50c8a78
2 changed files with 10 additions and 8 deletions
+9 -7
View File
@@ -353,10 +353,11 @@ var ReactMount = {
// verify that that's the case.
warning(
ReactCurrentOwner.current == null,
'_renderNewRootComponent(): Render methods should be a pure function ' +
'of props and state; triggering nested component updates from ' +
'%s._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.'
'componentDidUpdate.',
this.constructor.displayName || 'ReactCompositeComponent'
);
var componentInstance = instantiateReactComponent(nextComponent, null);
@@ -518,10 +519,11 @@ var ReactMount = {
// render but we still don't expect to be in a render call here.)
warning(
ReactCurrentOwner.current == null,
'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.'
'%s.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'
);
invariant(
@@ -826,7 +826,7 @@ describe('ReactCompositeComponent', function() {
ReactTestUtils.renderIntoDocument(<Outer />);
expect(console.warn.argsForCall.length).toBe(1);
expect(console.warn.argsForCall[0][0]).toBe(
'Warning: _renderNewRootComponent(): Render methods should ' +
'Warning: ReactCompositeComponent._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.'