breact
Version:
Browser react utility
22 lines (18 loc) • 588 B
JavaScript
/**
* Create an element
* @function create
* @param {Object} Component
* @param {Object} props
* @param {...Object} children - Child elements
* @returns {Object}
*/
const React = require('react')
/** @lends create */
function create (Component, props, ...children) {
Component = Component.default || Component
props = Object.assign({}, props) // Copy props to cut prototype chain
children = [].concat(children || []).reduce((children, child) => children.concat(child), [])
return React.createElement(Component, props, ...children)
}
module.exports = create