Allow children-only InfoBox without msg prop

This commit is contained in:
Maciej Ziarkowski 2021-03-11 19:09:22 +00:00
parent ec6e892aeb
commit b225a21f41

View File

@ -1,27 +1,19 @@
import React, { Fragment } from 'react'; import React from 'react';
interface InfoBoxProps { interface InfoBoxProps {
msg: string; msg?: string;
} }
const InfoBox: React.FC<InfoBoxProps> = (props) => ( const InfoBox: React.FC<InfoBoxProps> = (props) => (
<Fragment> <>
{ {
(props.msg || props.children)? (props.msg || props.children) &&
(
<div className="alert alert-info" role="alert"> <div className="alert alert-info" role="alert">
{ { props.msg ?? '' }
typeof props.msg === 'string' ? { props.children }
props.msg
: 'Enjoy the colouring! Usual service should resume shortly.'
}
{
props.children
}
</div> </div>
) : null
} }
</Fragment> </>
); );
export default InfoBox; export default InfoBox;