Rendering rich text in React Native
See original GitHub issueThanks to rich-text-react-render
, we can render Contentful rich text inside a React app. Moreover, some defaults are provided for DOM rendering (using tags like <p>
, <h1>
and so on).
However, it is not possible to render these tags in a React Native app, as React Native uses custom components, not DOM elements (for example <Text>
for text).
Fortunately, rich-text-react-renderer
makes possible to override the default components and allows to provide a custom renderer for each type of content.
Then, it is up to the user to provide their own React Native renderer.
Do you think it could be a good idea to provide a default renderer for React Native as well?
People might override it to use their own components for easier styling, but this could make it easier to get started using Contentful with React Native.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:15
- Comments:23 (5 by maintainers)
Top GitHub Comments
Since the react-renderer is flexible enough I think we can have a package that just exports a renderer option to add the
rich-text-react-renderer
Example:
For anyone looking for a solution, you can use this as a starting point. Your use case will be different based on where your using it, but for most people it’s enough to get started. I’ve edited the code inside the github comment box so if there is errors or formatting issues sorry about that.
And then you can do this: