diff --git a/src/renderers/shared/reconciler/ReactCompositeComponent.js b/src/renderers/shared/reconciler/ReactCompositeComponent.js index e7f220fe1b..199a4ebecb 100644 --- a/src/renderers/shared/reconciler/ReactCompositeComponent.js +++ b/src/renderers/shared/reconciler/ReactCompositeComponent.js @@ -809,16 +809,18 @@ var ReactCompositeComponentMixin = { var inst = this.getPublicInstance(); invariant(inst != null, 'Stateless function components cannot have refs.'); var publicComponentInstance = component.getPublicInstance(); - var componentName = component && component.getName ? - component.getName() : 'a component'; - warning(publicComponentInstance != null, - 'Stateless function components cannot be given refs ' + - '(See ref "%s" in %s created by %s). ' + - 'Attempts to access this ref will fail.', - ref, - componentName, - this.getName() - ); + if (__DEV__) { + var componentName = component && component.getName ? + component.getName() : 'a component'; + warning(publicComponentInstance != null, + 'Stateless function components cannot be given refs ' + + '(See ref "%s" in %s created by %s). ' + + 'Attempts to access this ref will fail.', + ref, + componentName, + this.getName() + ); + } var refs = inst.refs === emptyObject ? (inst.refs = {}) : inst.refs; refs[ref] = publicComponentInstance; },