Best way to support react-native? #162
-
Hello and happy new year! As the title suggests, I want to use remark / rehype to render markdown in a React Native application. I've already read about some other attempts, but the problem so far was how rehype handled text elements, so they can be transformed into components. Now, my question is: What would be the best/easiest solution for this? From my point of view, I see two options: The unified ecosystem can be a bit intimidating with all its plugins, different ASTs, parsers, and processors, so I am happy for any suggestion and wink in the right direction! :) Thanks in advance! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 13 replies
-
Welcome @bi3ri! 👋 As with so many things in Engineering "best" and "easiest" are very relative to what your goal is. 😉 🙂 For easiest, as in least code to maintain, you could leverage the existing If you want to avoid serializing to text before rendering. |
Beta Was this translation helpful? Give feedback.
Welcome @bi3ri! 👋
As with so many things in Engineering "best" and "easiest" are very relative to what your goal is. 😉 🙂
For easiest, as in least code to maintain, you could leverage the existing
rehype
ecosystem, and add an HTML to react-native translator on the tail end.There are some existing solutions like https://meliorence.github.io/react-native-render-html/ which can take HTML text and render it in
react-native
.If you want to avoid serializing to text before rendering.
I'd recommend leaning on https://github.com/rehypejs/rehype-react (a thing wrapper around https://github.com/syntax-tree/hast-util-to-jsx-runtime).
Rather than focusing on how to render, focus on how to adjust/rewo…