William Nguyen
William Nguyen

Reputation: 21

How to add line break into JS object that is passed as a property?

I use a JS helper file that consists of objects that are passed into a function that renders it. However, the \n doesn't work and I am not sure how to add line breaks. This is my helper list.

export const TweetList = [
{
    link: 'https://twitter.com/JayWuzer/status/1553804606265651200',
    tweet: "Being your full authentic self is a life hack. \n The ones who don't vibe with you will naturally be repulsed, and the ones who do vibe with you will naturally be drawn to you. \n Saves a LOT of time and heartache.",
    date: 7/31/2022
}, 

This is my function that renders the text. Could not format properly so I used an image instead.

Upvotes: 0

Views: 614

Answers (1)

Andrew
Andrew

Reputation: 31

you need to add styles

whiteSpace: 'pre-line'

Upvotes: 3

Related Questions