Anim8r
Anim8r

Reputation: 191

React-Native, keeping new lines "\n" from database

I'm trying to pull data from a database which provides a JSON response.

However no matter what I try, putting the variable into a <Text> prop always prints the "\n" as text on screen.

Is there any way either client or server side to allow new lines to properly make there way into the app?

Upvotes: 3

Views: 1210

Answers (1)

nirsky
nirsky

Reputation: 3105

That's how I handled this on my client side:

var response = fetch(...);
response = response.replace(/\\n/g,'\n');

Upvotes: 4

Related Questions