Created
September 11, 2018 10:09
-
-
Save Vadimhtml/221f68b7461dbb5f40d58020bf29c38a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface IPrimaryTextProps { | |
text:string|string[]; | |
} | |
function PrimaryText(props:IPrimaryTextProps) { | |
let text:Array<string | JSX.Element> | string = []; | |
if (_.isArray(props.text)) { | |
const items:Array<string | JSX.Element> = []; | |
props.text.map((value, index) => { | |
items.push(value); | |
if (props.text.length > 1 + index) { | |
items.push(<br key={index}/>); | |
} | |
}); | |
text = items; | |
} else { | |
text = props.text; | |
} | |
return <div className={style.PrimaryText}>{text}</div>; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment