Anuraag Basu
Anuraag Basu

Reputation: 9

react-native: display superscript text in Text component

I have the following text:

<div>Answer the following <span class='title'>Question:</span><br> (a+b)<sup>2</sup>=?</div>

I want to do the following with this text:

What I'm doing right now, is that I put the entire text (from start to end) in a Text component; and each span and br tags are also rendered as Text components nested within the parent Text component (the one for the div tag).
How do I render the superscript/subscript text?

Note: I did find a solution here: Superscript Text in React Native
But, creating a View inside a Text component needs the View to have fixed dimensions, and that is something not achievable.

Upvotes: 0

Views: 2315

Answers (1)

Athaphian
Athaphian

Reputation: 139

One option would be to convert the HTML to Markdown first and then render the markdown. I believe for both of those actions there are libraries available.

Upvotes: -1

Related Questions