dpatel125
dpatel125

Reputation: 121

How to place certain text in react native

I am trying to place some text in react native using the Text component and I am wondering how I would go about using it to place <-> in text in react native. I have tried placing it in the Text component like this

<Text><-></Text>

but this leads to errors and the app crashing.

the output I would like is for the text to look like this

Process 1 <-> Process 2

but errors come up instead.

Upvotes: 0

Views: 143

Answers (3)

Stuart Gough
Stuart Gough

Reputation: 1714

You can use the back quote `` to achieve what you want. Inserting reserved characters (< or >) as plain text can be done as shown below:

<Text>
   {`Process 1 <-> Process 2`}
</Text>

That should work as you intend

Upvotes: 0

Abraham
Abraham

Reputation: 9885

The only character that cannot be rendered normally in a Text it's < so you must put it inside curly braces as you were passing a variable.

Bad

<Text><</Text>

Good

<Text>{'<'}</Text>

Therefore you can do something like this:

<Text>Process 1 {'<'}-> Process 2</Text>

or like this:

<Text>{'Process 1 <-> Process 2'}</Text>

Upvotes: 1

Vinil Prabhu
Vinil Prabhu

Reputation: 1289

to display any characters in Text do this

<Text>{"Process 1 <-> Process 2"}</Text>

Upvotes: 0

Related Questions