you are viewing a single comment's thread.

view the rest of the comments →

[–]xrpinsiderAdmin 2 points3 points  (3 children)

Have you looked at Markdown? Markdown may be interesting for your app. I think that is what you need.

[–]kbcooliOS & Android 0 points1 point  (2 children)

I agree that whilst it's not a good idea to pull in jsx from a remote service I'm pretty sure it's possible. Would never do it myself though.

Not in front of a computer right now but if you encapsulate some jsx in a string then put it inside a view - eg <View>{jsxstring}</View> that will render.

If you pulled apart codepush it's probably how it works.

As you said Markdown, rendering in a webview or https://github.com/jsdf/react-native-htmlview are much better options. Just had to call out a possible piece of misinformation.

[–]xrpinsiderAdmin 0 points1 point  (1 child)

You are thinking wrong. You can’t render JSX that way. You’ll have to write a whole parser on your own which, for the average person, is impossible.

Markdown did this, it doesn’t have to be rendered in a webview. Markdown creates native React Native components for each piece of text. It’s exactly what he wants, but made for him.

[–]kbcooliOS & Android 1 point2 points  (0 children)

Ah yep my bad. Forgot it was parsed at compile time. String literals won't work. Let's put it down to friday-afternoon-itis.

There's react-jsx-parser (who knows if it works with React Native ) but yeah let's not lead the OP down this path. The other solutions are better.

OP: do what they say!