{"size": 785, "ext": "js", "max_stars_repo_path": "src/Destination.js", "max_stars_repo_name": "nabepon/react-transfer", "max_stars_repo_stars_event_min_datetime": "2017-07-05T08:08:29.000Z", "max_stars_repo_stars_event_max_datetime": "2017-07-05T08:08:29.000Z", "max_issues_repo_path": "src/Destination.js", "max_issues_repo_name": "nabepon/react-transfer", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Destination.js", "max_forks_repo_name": "nabepon/react-transfer", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 1, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 27.0689655172, "max_line_length": 100, "alphanum_fraction": 0.6369426752}
import React, { Component } from "react";
import PropTypes from "prop-types";

export default class Destination extends Component {
  static contextTypes = {
    transferContext: PropTypes.object
  };
  render() {
    const {
      collect,
      component,
      children,
      ...restProps
    } = this.props;
    const propsObj = this.context.transferContext.components[collect];
    if(!propsObj) {
      return null;
    }
    const propsArray = Object.keys(propsObj).reduce((result, key) => {
      if(propsObj[key]) {
        result.push(propsObj[key]);
      }
      return result;
    }, []);
    const components = (children ? children(propsArray) : propsArray).map(props => props.children) ;
    return React.createElement(component || "div", restProps, components);
  }
}
