react-conditional-components-renderer
Version:
React library with conditional components to rendering
21 lines (20 loc) • 535 B
JavaScript
;
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;