UNPKG

@shopgate/engage

Version:
9 lines 1.02 kB
function _extends(){_extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};return _extends.apply(this,arguments);}import React from'react';import AppContext from"../contexts/AppContext";/** * Injects the AppContext properties into the desired component within a prop named "app". * @param {Function} WrappedComponent The react component to wrap. * @returns {JSX} */export function withApp(WrappedComponent){/** * The actual HOC. * @param {Object} props The component props. * @returns {JSX} */var WithApp=function WithApp(props){return React.createElement(AppContext.Consumer,null,function(appContext){return React.createElement(WrappedComponent,_extends({app:appContext},props));});};var displayName=WrappedComponent.displayName||WrappedComponent.name||'Component';WithApp.displayName="WithApp(".concat(displayName,")");return WithApp;}