fix: do not render empty instructions

pull/25124/head^2
Ahmad Abdolsaheb 2019-02-15 17:51:43 +03:00 committed by Valeriy
parent 150d655306
commit e727acb281
1 changed files with 7 additions and 4 deletions

View File

@ -9,19 +9,22 @@ const propTypes = {
section: PropTypes.string
};
function emptyInstruction(instructions) {
return (/^<section\s+id\s*=\s*("|')instructions\1\s*>\s*<\/section>$/)
.test(instructions);
}
function ChallengeDescription({ description, instructions, section }) {
return (
<div className={`challenge-instructions ${section}`}>
<div dangerouslySetInnerHTML={{ __html: description }} />
{instructions ? (
{!emptyInstruction(instructions) && (
<Fragment>
<hr />
<div dangerouslySetInnerHTML={{ __html: instructions }} />
<hr />
</Fragment>
) : (
<hr />
)}
<hr />
</div>
);
}