I received this string: Ticket #: 9 (ORIGINAL)nDate/Time: 12/10/2020 03:33 PM
from an API, I want to breakline using n and I use useState to print it:
const [Ticket, setTicket] = useState('');
const getData = async (ID, Serial) => {
try{
const res = await FetchRewards(ID, Serial)
console.log('%c Ticket has been found Successfully. Status: 200 ',
'background: #28a745; color: #fff')
setTicket(res.data.ticket.ticket);
console.log(res)
}
catch (err){
console.error("404: Ticket not found")
}
}
but my problem is trying to make split on Ticket to make breaklines using n, this is my split function to do that:
const text = `Ticket #: 9 (ORIGINAL)nDate/Time: 12/10/2020 03:33 PM`;
let ticketWrap = text.split("n").map(i =>{
return `<p>${i}</p>`; // this is JSX in my real code
});
console.log(ticketWrap)
When I add a text with n,ticketWrap returns the breakline, but using Ticket it returns: Ticket #: 9 (ORIGINAL)nDate/Time: 12/10/2020 03:33 PM