em-cmp-lib-prototypes
Version: 
components library for prototypes
48 lines (40 loc) • 1.21 kB
JSX
import React from 'react';
import PropTypes from 'prop-types';
const propTypes = {
  cmpConfig: PropTypes.object,
  context: PropTypes.object,
  services: PropTypes.object,
};
const defaultProps = {
  cmpConfig: {},
  context: {},
  services: {},
};
class Component extends React.Component {
  constructor(props) {
    super(props);
    this.services = this.props.services;
    this.services.pubSub = this.props.services.pubSubService.getPubSubInstance();
    this.services.restClient = this.services.fareRestClient;
    this.lang = this.props.cmpConfig.containerConfig.settings.lang;
  }
  render() {
    const ContainerComponent = this.props.cmpConfig.containerConfig.instance;
    return (
      <div>
        <ContainerComponent
          components={this.props.cmpConfig.containerConfig.components}
          services={this.services}
          model={this.props.cmpConfig.containerConfig.model}
          {...this.props.cmpConfig.containerConfig.settings}
          cmpConfig={this.props.cmpConfig}
          context={this.props.context}
          lang={this.lang}
        />
      </div>
    );
  }
}
Component.propTypes = propTypes;
Component.defaultProps = defaultProps;
export default Component;