How to use the airbnb-prop-types/build/helpers/getComponentName function in airbnb-prop-types

To help you get started, we’ve selected a few airbnb-prop-types examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github airbnb / react-with-styles / src / withStyles.jsx View on Github external
return function withStylesHOC(WrappedComponent) {
    const wrappedComponentName = getComponentName(WrappedComponent);

    // The wrapper component that injects the withStyles props
    class WithStyles extends BaseClass {
      constructor(props, context) {
        super(props, context);

        /** Cache for storing the current props and objects used to derive them */
        this.cache = { rtl: {}, ltr: {} };
      }

      getCache(direction) {
        return this.cache[direction];
      }

      updateCache(direction, results) {
        this.cache[direction] = results;
github airbnb / react-with-direction / src / withDirection.jsx View on Github external
}
    }

    render() {
      const { direction } = this.state;

      return (
        
      );
    }
  }

  const wrappedComponentName = getComponentName(WrappedComponent) || 'Component';

  WithDirection.WrappedComponent = WrappedComponent;
  WithDirection.contextTypes = contextTypes;
  WithDirection.displayName = `withDirection(${wrappedComponentName})`;
  if (WrappedComponent.propTypes) {
    WithDirection.propTypes = deepmerge({}, WrappedComponent.propTypes);
    delete WithDirection.propTypes.direction;
  }
  if (WrappedComponent.defaultProps) {
    WithDirection.defaultProps = deepmerge({}, WrappedComponent.defaultProps);
  }

  return hoistNonReactStatics(WithDirection, WrappedComponent);
}
github airbnb / react-create-hoc / src / index.js View on Github external
return function hoc(ComponentToWrap, ...hocParams) {
      const NewComponent = componentAndParamsToComponent(
        ComponentToWrap,
        ...(factory ? factoryParams : hocParams),
      );

      NewComponent.WrappedComponent = ComponentToWrap;
      NewComponent.displayName = `${hocName}(${getComponentName(ComponentToWrap)})`;

      if (ComponentToWrap.propTypes) {
        const copiedProps = {
          ...sloppy(ComponentToWrap.propTypes),
        };

        passedProps.forEach((propName) => {
          delete copiedProps[propName];
        });

        const newPropTypes = {
          ...copiedProps,
          ...(NewComponent.propTypes && sloppy(NewComponent.propTypes)),
        };

        if (allowExtraProps) {