diff --git a/src/renderers/shared/stack/reconciler/ReactCompositeComponent.js b/src/renderers/shared/stack/reconciler/ReactCompositeComponent.js index 6ac4ab1796b8a..eee5b48f8e954 100644 --- a/src/renderers/shared/stack/reconciler/ReactCompositeComponent.js +++ b/src/renderers/shared/stack/reconciler/ReactCompositeComponent.js @@ -1107,7 +1107,7 @@ var ReactCompositeComponent = { if (__DEV__) { var componentName = component && component.getName ? component.getName() : 'a component'; - warning(publicComponentInstance != null, + warning(publicComponentInstance != null || component.toJSON, 'Stateless function components cannot be given refs ' + '(See ref "%s" in %s created by %s). ' + 'Attempts to access this ref will fail.', diff --git a/src/renderers/testing/__tests__/ReactTestRenderer-test.js b/src/renderers/testing/__tests__/ReactTestRenderer-test.js index e562867fd2dbb..0885f0809254f 100644 --- a/src/renderers/testing/__tests__/ReactTestRenderer-test.js +++ b/src/renderers/testing/__tests__/ReactTestRenderer-test.js @@ -206,6 +206,17 @@ describe('ReactTestRenderer', function() { expect(log).toEqual([null]); }); + it('does not warn with legacy refs', function() { + spyOn(console, 'error'); + class Foo extends React.Component { + render() { + return
+ } + } + ReactTestRenderer.create(