Alba
Alba

Reputation: 109

New line break issue

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;
}

Upvotes: 0

Views: 65

Answers (2)

0xkvn
0xkvn

Reputation: 386

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.

Upvotes: 1

delimiter
delimiter

Reputation: 795

Try using <br> instead of \n.

Upvotes: 1

Related Questions