0

Somehow a new line does not get started in my popup when I am using \n

Please see a code sample below.

data.forEach((element) => {
  dataClean.push({
    position: { lng: element.Longitude, lat: element.Latitude },
    text: priceData(element)
  });
}); 

function priceData(element) {
  let labelText = `No.: ${element.Number}, ${element.Bedrooms} rooms\n
  ${element.Address}\n\n`;
  const data = element.history;
  data[0].forEach((element, indx) => {
    labelText = `${labelText} ∙ ${element}: ${data[1][indx]} \n`;
  });

  labelText = `${labelText}\n${element.days} days\nstatus: ${element.status}`;

  return labelText;
}
Alba
  • 109
  • 8

2 Answers2

1

Try using <br> instead of \n.

delimiter
  • 745
  • 4
  • 13
1

If by popup you actually mean a modal, try adding this css property to the element containing your text:

white-space: pre;

EDIT: Don't see no mention of React Native in your original post, so obviously my answer can help only if we're talking about a classic web project, not a React Native one.

0xkvn
  • 377
  • 2
  • 16