Rendering comma separated list of links

后端 未结 10 1626
再見小時候
再見小時候 2020-12-24 00:58

I\'m trying to output a list of comma separated links and this is my solution.

var Item = React.createComponent({
  render: function() {

    var tags = [],
         


        
10条回答
  •  春和景丽
    2020-12-24 01:32

    Simply

    {tags.map((tag, i) => 
        {i > 0 && ", "}
        
    )}
    


    In React 16 it can be done even more simpler:

    {tags.map((tag, i) => [
        i > 0 && ", ",
        
    ])}
    

提交回复
热议问题