How to render react components by using map and join?

后端 未结 14 2176
南旧
南旧 2020-12-07 15:30

I have one component which is going to display Array of String. The code looks like this:

React.createClass({
  render() {
     
this.props
14条回答
  •  南方客
    南方客 (楼主)
    2020-12-07 16:02

    This should return a flat array. Handle s case with non iterable first object by providing an initial empty array and filters the not needed first comma from the outcome

    [{}, 'b', 'c'].reduce((prev, curr) => [...prev, ', ', curr], []).splice(1) // => [{}, 'b', 'c']
    

提交回复
热议问题