0

(Current Output):

Coming Soon Shortly <br /> Coming Soon Shortly <br /> Coming Soon Shortly

When I put in <Text> , it shows <br> tag as it is , instead of going to the next line

(Expected output):

Coming Soon Shortly

Coming Soon Shortly

Coming Soon Shortly

Paritosh
  • 11,144
  • 5
  • 56
  • 74
rajat44
  • 4,941
  • 6
  • 29
  • 37

4 Answers4

1

I'll assume you meant <textarea>. To put a new line use:

&#13;&#10;

Example:

<textarea>Hello World&#13;&#10;How are you?</textarea>
Mr Lister
  • 45,515
  • 15
  • 108
  • 150
Lulceltech
  • 1,662
  • 11
  • 22
  • I am getting
    tag along with some text from API . I want to break the line when
    tag comes , but instead, it showing
    tag in output. Output in emulator comes out to be Coming Soon Shortly < br > Coming Soon Shortly< br >Coming Soon Shortly" instead of : Coming Soon Shortly Coming Soon Shortly Coming Soon Shortly"
    – rajat44 Aug 27 '16 at 08:19
  • You'll have to use java script to replace the
    with or use a backend to do that with php before it populates the text area.
    – Lulceltech Aug 27 '16 at 08:20
  • I have tried using it Hello World How are you? still it is showing the text in same line . what do you suggest now ? – rajat44 Aug 27 '16 at 08:32
  • 1
    @rajat44 There is no such thing as ``. So what did you mean instead? I guess that Tim's assumption is not correct, so what is it? Did you mean SVG ``? If so, the question should have been tagged [svg], and you should have written `` in lowercase, since svg is case sensitive. Or are you just inventing new tag names as you go along? – Mr Lister Aug 28 '16 at 08:31
  • @MrLister There is a tag in **"REACT NATIVE"**. I don't know why you and Tim are not getting it. if I put a HTML tag in my it is getting printed as a text . for ex - hi my name is
    Rajat
    Gupta
    Expected output is:- hi my name is (next line)Rajat (next line)Gupta but it is coming as :- hi my name is
    Rajat
    Gupta. I hope you get it now .
    – rajat44 Aug 28 '16 at 11:49
1

You might want to try this plugin: https://github.com/taskrabbit/react-native-parsed-text

then try to define your own Regex pattern (as @farwayer sample)

TeYoU
  • 844
  • 7
  • 13
0

For reactJs you can use dangerouslySetInnerHTML property to set content as HTML.

Abdullah Khan
  • 12,010
  • 6
  • 65
  • 78
0
text = text.replace(/<\s*br\s*\/*\s*>/gi, '\n')
farwayer
  • 3,872
  • 3
  • 21
  • 23