代码实现:
const If = props => {
const condition = props.condition || false;
const positive = props.then || null;
const negative = props.else || null;
return condition ? positive : negative;
};
应用:
<If
condition={判断条件}
then={}
else={}
/>