UNPKG

catreact

Version:

Catavolt Core React Components

31 lines (30 loc) 937 B
/** * Created by rburson on 1/11/16. */ "use strict"; var React = require('react'); var catreact_core_1 = require('./catreact-core'); /* *************************************************** * Exposes the scope of the enclosing tag via the handler function *************************************************** */ exports.CvScope = React.createClass({ mixins: [catreact_core_1.CvBaseMixin], getDefaultProps: function () { return { handler: null, get: null }; }, render: function () { if (this.scopeCtx().scopeObj) { var scopeObj = this.scopeCtx().scopeObj; if (this.props.get) { var value = scopeObj[this.props.get]; return value ? React.createElement("span", null, value) : null; } else if (this.props.handler) { return this.props.handler(scopeObj); } } return null; }, });