How to render react components by using map and join?

后端 未结 14 2200
南旧
南旧 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条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-07 15:47

    Update with React 16: It's now possible to render strings directly, so you can simplify your code by removing all the useless tags.

    const list = ({ data }) => data.reduce((prev, curr) => [ prev, ', ', curr ]);
    

提交回复
热议问题