Reputation: 121
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
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
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
Reputation: 1289
to display any characters in Text
do this
<Text>{"Process 1 <-> Process 2"}</Text>
Upvotes: 0