How to use hoist-non-react-statics - 10 common examples

To help you get started, we’ve selected a few hoist-non-react-statics 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 deranjer / goTorrent / goTorrentWebUI / node_modules / material-ui / es / styles / withTheme.js View on Github external
themeListener.unsubscribe(this.context, this.unsubscribeId);
      }
    }

    render() {
      return React.createElement(Component, _extends({ theme: this.state.theme }, this.props));
    }
  }

  WithTheme.contextTypes = themeListener.contextTypes;

  if (process.env.NODE_ENV !== 'production') {
    WithTheme.displayName = wrapDisplayName(Component, 'WithTheme');
  }

  hoistNonReactStatics(WithTheme, Component);

  if (process.env.NODE_ENV !== 'production') {
    // Exposed for test purposes.
    WithTheme.Naked = Component;
  }

  return WithTheme;
};
github withspectrum / spectrum / mobile / components / SafeAreaView / index.js View on Github external
export default function withSafeAreaView(WrappedComponent: Node): () => Node {
  function EnhancedComponent(props: any) {
    return (
      
        {/* $FlowFixMe */}
        
      
    );
  }
  return hoistNonReactStatics(EnhancedComponent, WrappedComponent);
}
github cssinjs / jss / packages / react-jss / src / withStyles.js View on Github external
)}
              
            )
          }

          return 
        }}
      
    ))

    JssContextSubscriber.displayName = `JssContextSubscriber(${displayName})`
    // $FlowFixMe - React's types should allow custom static properties on component.
    JssContextSubscriber.InnerComponent = InnerComponent

    return hoistNonReactStatics(JssContextSubscriber, InnerComponent)
  }
}
github catamphetamine / react-pages / source / redux / on enter.js View on Github external
return function(Wrapped)
	{
		class On_enter extends Component
		{
			render()
			{
				return 
			}
		}

		On_enter.displayName = `onEnter(${get_display_name(Wrapped)})`

		hoist_statics(On_enter, Wrapped)

		const preloader = On_enter[Preload_method_name]

		On_enter[Preload_method_name] = function on_enter_then_preload(parameters)
		{
			let redirect_to
			const redirect = to => redirect_to = to

			const proceed = () => preloader ? preloader(parameters) : Promise.resolve()

			const on_enter_result = on_enter(parameters, redirect)

			// If it's not a Promise, then just proceed
			if (!on_enter_result.then)
			{
				return proceed()
github greenbone / gsa / gsa / src / web / utils / withContext.js View on Github external
const withContext = contextTypes => Component => {
  const ContextWrapper = (props, context) => (
    
  );

  ContextWrapper.contextTypes = contextTypes;

  return hoistStatics(ContextWrapper, Component);
};
github folio-org / stripes-core / src / stripesConnect.js View on Github external
class ConnectedComponent extends Component {
    static propTypes = {
      stripes: stripesShape.isRequired
    }

    constructor(props) {
      super(props);
      this.connectedComponent = props.stripes.connect(WrappedComponent, options);
    }

    render() {
      return ;
    }
  }

  return withStripes(hoistNonReactStatics(ConnectedComponent, WrappedComponent));
}
github pct-org / native-app / app / modules / GraphQL / withApollo.js View on Github external
export const withApollo = Component => hoistNonReactStatics(
  React.forwardRef((props, ref) => (
    
      {client => }
    
  )),
  Component,
)
github adam-26 / react-router-dispatcher / src / createRouteDispatchers.js View on Github external
function RouteDispatcherHoc(displayNamePrefix, routeConfig, options) {
    const routerDispatcher = ({ routes, ...props }) => {
        return (
            );
    };

    routerDispatcher.displayName = `${displayNamePrefix}(${reactDisplayName(RouteDispatcher)})`;

    routerDispatcher.propTypes = RouteDispatcher.propTypes;

    return hoistNonReactStatic(routerDispatcher, RouteDispatcher);
}
github traveloka / soya-next / packages / soya-next / src / router / applyRedirect.js View on Github external
export default Page =>
  hoistStatics(
    class extends React.Component {
      static displayName = getDisplayName("applyRedirect", Page);

      static async getInitialProps(ctx) {
        const {
          defaultLocale,
          locale,
          method,
          redirects = {},
          siteLocales
        } = process.browser ? window.__NEXT_DATA__.props : ctx.req;
        if (process.browser) {
          for (const from of Object.keys(redirects)) {
            const { method: redirectMethod, page, to } = ensureRedirect(
              redirects[from]
            );
github ryandrewjohnson / react-localize-redux / src / withLocalize.js View on Github external
export function withLocalize(
  WrappedComponent: ComponentType
): ComponentType<$Diff> {
  class LocalizedComponent extends Component {
    render() {
      return (
        
          {context => }
        
      );
    }
  }
  hoistNonReactStatic(LocalizedComponent, WrappedComponent);
  return LocalizedComponent;
}

hoist-non-react-statics

Copies non-react specific statics from a child component to a parent component

BSD-3-Clause
Latest version published 5 years ago

Package Health Score

70 / 100
Full package analysis

Popular hoist-non-react-statics functions