From 28f50c8a78cffc0b0e9d60e4a7c77cc14a8e80c7 Mon Sep 17 00:00:00 2001 From: Ben Moss Date: Mon, 26 Jan 2015 14:14:27 -0500 Subject: [PATCH] Add displayName to nested render warnings [#1726] --- src/browser/ui/ReactMount.js | 16 +++++++++------- .../__tests__/ReactCompositeComponent-test.js | 2 +- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/browser/ui/ReactMount.js b/src/browser/ui/ReactMount.js index a71b2311d4..237c9528fb 100644 --- a/src/browser/ui/ReactMount.js +++ b/src/browser/ui/ReactMount.js @@ -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( diff --git a/src/core/__tests__/ReactCompositeComponent-test.js b/src/core/__tests__/ReactCompositeComponent-test.js index ee705d4e2f..c3b040c0b7 100644 --- a/src/core/__tests__/ReactCompositeComponent-test.js +++ b/src/core/__tests__/ReactCompositeComponent-test.js @@ -826,7 +826,7 @@ describe('ReactCompositeComponent', function() { ReactTestUtils.renderIntoDocument(); 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.'