Merge remote-tracking branch 'origin/feature/Detail'

This commit is contained in:
a.bouhuolia
2021-08-25 16:10:13 +02:00
61 changed files with 1668 additions and 277 deletions

View File

@@ -2,32 +2,32 @@ import React from 'react';
import PropTypes from 'prop-types';
import If from './If';
const Choose = props => {
let when = null;
let otherwise = null;
const Choose = (props) => {
let when = null;
let otherwise = null;
React.Children.forEach(props.children, children => {
if (children.props.condition === undefined) {
otherwise = children;
} else if (!when && children.props.condition === true) {
when = children;
}
});
React.Children.forEach(props.children, (children) => {
if (children.props.condition === undefined) {
otherwise = children;
} else if (!when && children.props.condition === true) {
when = children;
}
});
return when || otherwise;
return when || otherwise;
};
Choose.propTypes = {
children: PropTypes.node
children: PropTypes.node,
};
Choose.When = If;
Choose.Otherwise = ({render, children}) => render ? render() : children;
Choose.Otherwise = ({ render, children }) => (render ? render() : children);
Choose.Otherwise.propTypes = {
children: PropTypes.node,
render: PropTypes.func
render: PropTypes.func,
};
export default Choose;
export default Choose;