let { isArray } = require('../mindash');
let findApp = require('../core/findApp');

module.exports = function (React) {
  let ApplicationContainer = React.createClass({
    childContextTypes: {
      app: React.PropTypes.object
    },
    getChildContext() {
      return { app: findApp(this) };
    },
    render() {
      let { app, children } = this.props;

      if (children) {
        if (isArray(children)) {
          return <span>{React.Children.map(children, cloneElementWithApp)}</span>;
        } else {
          return cloneElementWithApp(children);
        }
      }

      function cloneElementWithApp(element) {
        return React.addons.cloneWithProps(element, {
          app: app
        });
      }
    }
  });

  return ApplicationContainer;
};
let findApp = require('../core/findApp');
let { isArray, extend } = require('../mindash');

module.exports = function (React) {
  let ApplicationContainer = React.createClass({
    childContextTypes: {
      app: React.PropTypes.object
    },
    getChildContext() {
      return { app: findApp(this) };
    },
    render() {
      let { app, children } = this.props;

      if (children) {
        if (isArray(children)) {
          return <span>{React.Children.map(children, cloneWithApp)}</span>;
        } else {
          return cloneWithApp(children);
        }
      }

      function cloneWithApp(element) {
        return React.createElement(element.type, extend({
          app: app
        }, element.props));
      }
    }
  });

  return ApplicationContainer;
};
Clone the element without using addons
Clone the element without using addons
