export default function getComponentName(target: ComponentType<*>): string { return ( (process.env.NODE_ENV !== 'production' ? typeof target === 'string' && target : false) || target.displayName || target.name || 'Component' ); }
setNativeProps(nativeProps: Object) { if (this.root !== undefined) { // $FlowFixMe this.root.setNativeProps(nativeProps); } else if (process.env.NODE_ENV !== 'production') { // eslint-disable-next-line no-console console.warn( 'setNativeProps was called on a Styled Component wrapping a stateless functional component.' ); } }
render() { const { children, sheet, target } = this.props; return ( <StyleSheetContext.Provider value={this.getContext(sheet, target)}> {process.env.NODE_ENV !== 'production' ? React.Children.only(children) : children} </StyleSheetContext.Provider> ); }
describe('production', () => { beforeEach(() => { process.env.NODE_ENV = 'production'; }); it('returns an error link', () => { expect(() => { throw new StyledError(2); }).toThrowErrorMatchingSnapshot(); }); it('returns an error link with interpolations if given', () => { expect(() => { throw new StyledError(1, 'foo'); }).toThrowErrorMatchingSnapshot(); }); });
generateAndInjectStyles(theme: any, props: any) { const { attrs, componentStyle, warnTooManyClasses } = props.forwardedComponent; // statically styled-components don't need to build an execution context object, // and shouldn't be increasing the number of class names if (componentStyle.isStatic && !attrs.length) { return componentStyle.generateAndInjectStyles(EMPTY_OBJECT, this.styleSheet); } const className = componentStyle.generateAndInjectStyles( this.buildExecutionContext(theme, props, attrs), this.styleSheet ); if (process.env.NODE_ENV !== 'production' && warnTooManyClasses) warnTooManyClasses(className); return className; }
/** * Get the theme from the props, supporting both (outerTheme) => {} * as well as object notation */ getTheme(theme: (outerTheme: ?Theme) => void, outerTheme: ?Theme) { if (isFunction(theme)) { const mergedTheme = theme(outerTheme); if ( process.env.NODE_ENV !== 'production' && (mergedTheme === null || Array.isArray(mergedTheme) || typeof mergedTheme !== 'object') ) { throw new StyledError(7); } return mergedTheme; } if (theme === null || Array.isArray(theme) || typeof theme !== 'object') { throw new StyledError(8); } return { ...outerTheme, ...theme }; }
afterEach(() => { process.env.NODE_ENV = 'test'; });
if (node.type === 'decl') { declPairs.push([node.prop, node.value]); } else if (process.env.NODE_ENV !== 'production' && node.type !== 'comment') {
server = await startServer(app, PORT); browser = await puppeteer.launch({ executablePath: process.env.GOOGLE_CHROME_BINARY || undefined, args: ['--no-sandbox', '--disable-setuid-sandbox', '--disable-lcd-text'], });
export default function keyframes( strings: Styles, ...interpolations: Array<Interpolation> ): Keyframes { /* Warning if you've used keyframes on React Native */ if ( process.env.NODE_ENV !== 'production' && typeof navigator !== 'undefined' && navigator.product === 'ReactNative' ) { // eslint-disable-next-line no-console console.warn( '`keyframes` cannot be used on ReactNative, only on the web. To do animation in ReactNative please use Animated.' ); } const rules = css(strings, ...interpolations); const name = generateAlphabeticName(hashStr(replaceWhitespace(JSON.stringify(rules)))); return new Keyframes(name, stringifyRules(rules, name, '@keyframes')); }
if (forwardedRef) propsForElement.ref = forwardedRef; if (process.env.NODE_ENV !== 'production' && innerRef) { this.warnInnerRef(displayName);
React.forwardRef((props, ref) => ( <ThemeConsumer> {(theme?: Theme) => { // $FlowFixMe const { defaultProps } = Component; const themeProp = determineTheme(props, theme, defaultProps); if (process.env.NODE_ENV !== 'production' && themeProp === undefined) { // eslint-disable-next-line no-console console.warn( `[withTheme] You are not using a ThemeProvider nor passing a theme prop or a theme in defaultProps in component class "${getComponentName( Component )}"` ); } return <Component {...props} theme={themeProp} ref={ref} />; }} </ThemeConsumer> ))
this.renderInner = this.renderInner.bind(this); if (process.env.NODE_ENV !== 'production') { this.warnInnerRef = once(displayName =>
constructor(code: string | number, ...interpolations: Array<any>) { if (process.env.NODE_ENV === 'production') { super( `An error occurred. See https://github.com/styled-components/styled-components/blob/master/packages/styled-components/src/utils/errors.md#${code} for more information.${ interpolations.length > 0 ? ` Additional arguments: ${interpolations.join(', ')}` : '' }` ); } else { super(format(ERRORS[code], ...interpolations).trim()); } }
constructor(props) { super(props); if (process.env.NODE_ENV !== 'production') { this.warnInnerRef = once(displayName =>