Don't render Markdown if input or sanitized input is empty

This commit is contained in:
Kyle Shockey
2017-06-22 22:05:38 -07:00
parent c0a700346b
commit 21100a0a8b

View File

@@ -11,6 +11,12 @@ const sanitizeOptions = {
function Markdown({ source }) { function Markdown({ source }) {
const sanitized = sanitize(source, sanitizeOptions) const sanitized = sanitize(source, sanitizeOptions)
// sometimes the sanitizer returns "undefined" as a string
if(!source || !sanitized || sanitized === "undefined") {
return null
}
return <Remarkable return <Remarkable
options={{html: true, typographer: true, linkify: true, linkTarget: "_blank"}} options={{html: true, typographer: true, linkify: true, linkTarget: "_blank"}}
source={sanitized} source={sanitized}