UNPKG

react-conditional-components-renderer

Version:
21 lines (20 loc) 535 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const Choice = (props) => { let defaultChoice = []; const choice = props.children.find((child) => { if (child.props.test != undefined) { return child.props.test ? child : null; } else { defaultChoice.push(child); } return null; }); return choice ? choice : defaultChoice.length > 0 ? defaultChoice[0] : null; }; exports.default = Choice;