I have one component which is going to display Array of String. The code looks like this:
React.createClass({
render() {
this.props
function YourComponent(props) {
const criteria = [];
if (something) {
criteria.push({ something });
}
// join the jsx elements with `, `
const elements = criteria.reduce((accu, elem) => {
return accu === null ? [elem] : [...accu, ', ', elem]
}, null);
// render in a jsx friendly way
return elements.map((el, index) => { el } );
}