@samitouri / QOS-React-2 / commits / c6a3eb14db

Wrapping StatelessComponent ref warning in __DEV__ block

Bradley Spaulding committed Oct 5, 2015 at 21:44 UTC c6a3eb14db57e3663f749cd288288640f4f2d59d
1 file changed +12 -10
src/renderers/shared/reconciler/ReactCompositeComponent.js
+12 -10
@@ -809,16 +809,18 @@ var ReactCompositeComponentMixin = {
809 var inst = this.getPublicInstance();
810 invariant(inst != null, 'Stateless function components cannot have refs.');
811 var publicComponentInstance = component.getPublicInstance();
812 - var componentName = component && component.getName ?
813 - component.getName() : 'a component';
814 - warning(publicComponentInstance != null,
815 - 'Stateless function components cannot be given refs ' +
816 - '(See ref "%s" in %s created by %s). ' +
817 - 'Attempts to access this ref will fail.',
818 - ref,
819 - componentName,
820 - this.getName()
821 - );
812 + if (__DEV__) {
813 + var componentName = component && component.getName ?
814 + component.getName() : 'a component';
815 + warning(publicComponentInstance != null,
816 + 'Stateless function components cannot be given refs ' +
817 + '(See ref "%s" in %s created by %s). ' +
818 + 'Attempts to access this ref will fail.',
819 + ref,
820 + componentName,
821 + this.getName()
822 + );
823 + }
824 var refs = inst.refs === emptyObject ? (inst.refs = {}) : inst.refs;
825 refs[ref] = publicComponentInstance;
826 },