Home > OS >  js join("\n") not start at new line
js join("\n") not start at new line

Time:02-14

I am using antd table,and this is one of my columns,I would like to show every name at new line,I am using "\n" but it was not working,it was just spacing,not start the second name at the new line

{
            title: "Borrower Name",
            width: 150,
            dataIndex: "borrower",
            render: (record) => record.map((a) => a.name).join("\n"),
}

CodePudding user response:

Another solution is using HTML tag (i have used paragraph tag), this will display all the names on new line.

{
  title: 'Borrower Name',
  width: 150,
  dataIndex: 'borrower',
  render: (record) => record.map((a) => <p>{a.name}</p>),
},

CodePudding user response:

map() function should return something, Should be like this:

render: (record) => record.map(a => {return a.name}).join("\n")

  • Related