const { h } = require('hyperscript-jsx/string') module.exports = function (Master, Component) { const locals = Object.assign({ query: this.req.query }, this.app.locals, this.locals) if (typeof Master === 'function') { if (typeof Component === 'function') { return this.send( h(Master, locals, h(Component, locals) ) ) } Component = Master } if (typeof Component !== 'function') { throw new Error('Not a Component') } else if (Component.prototype && Component.prototype.render) { const i = new Component(locals) this.send(i.render(i.props, i.state)) } else { this.send(Component(locals)) } }