import _ from 'lodash'; import React, { Component } from 'react'; const instance = (value) => ( _.isFunction(value) ? value() : (value || null) ); export class If extends Component { render() { return this.props.if ? instance(this.props.then) : instance(this.props.else); }; }; export class Case extends Component { render() { const val = this.props.switch; for(let i = 0; i < 999; ++i) { if(this.props['case' + i] === undefined) return instance(this.props.else); if(this.props['case' + i] === val) return instance(this.props['then' + i]); } return null; }; };