score:1

Accepted answer

you can do that using regular expressions.
first, replace line breaks with '\n' in your textarea value.

inputvalue.replace(/\n/g, "\\n");

now send this new value to firestore.
to display the value again reverse the procedure.

receivedvalue.replace(/\\n/g, "\n");

example

score:0

adding to the above answer. if you have something with "return keys" even in your state you would need to add

<div style = {{ whitespace: 'pre-line'}}

this template literal is needed for you to have the return keys in your html. otherwise, they will automatically be replaced with spaces.


Related Query

More Query from same tag