UNPKG

@yncoder/element-react

Version:
47 lines (36 loc) 1.42 kB
import _extends from 'babel-runtime/helpers/extends'; import _classCallCheck from 'babel-runtime/helpers/classCallCheck'; import _possibleConstructorReturn from 'babel-runtime/helpers/possibleConstructorReturn'; import _inherits from 'babel-runtime/helpers/inherits'; import React, { Component } from 'react'; import PropTypes from 'prop-types'; var View = function (_Component) { _inherits(View, _Component); function View() { _classCallCheck(this, View); return _possibleConstructorReturn(this, _Component.apply(this, arguments)); } View.prototype.render = function render() { var classNames = []; var _props = this.props, _props$show = _props.show, show = _props$show === undefined ? true : _props$show, _props$className = _props.className, className = _props$className === undefined ? '' : _props$className, children = _props.children; var mixed = { style: _extends({}, children.props.style) }; if (!show) mixed.style.display = 'none'; if (children.props.className) classNames.push(children.props.className); if (className) classNames.push(className); mixed.className = classNames.join(' '); return React.cloneElement(React.Children.only(children), mixed); }; return View; }(Component); /* eslint-disable */ export default View; View.propTypes = { show: PropTypes.any }; /* eslint-enable */ View._typeName = 'View';