Skip to content

Instantly share code, notes, and snippets.

@Vadimhtml
Created September 11, 2018 10:09
Show Gist options
  • Save Vadimhtml/221f68b7461dbb5f40d58020bf29c38a to your computer and use it in GitHub Desktop.
Save Vadimhtml/221f68b7461dbb5f40d58020bf29c38a to your computer and use it in GitHub Desktop.
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