Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0847ded

Browse files
committed
doc(README): explain how to make inline custom renderers
1 parent b35dde0 commit 0847ded

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ An iOS/Android pure javascript react-native component that renders your HTML int
1616
- [Demo](#demo)
1717
- [Creating custom renderers](#creating-custom-renderers)
1818
- [Custom HTML tags](#custom-html-tags)
19+
- [Making your custom component block or inline](#making-your-custom-component-block-or-inline)
1920
- [Lists prefixes](#lists-prefixes)
2021
- [Styling](#styling)
2122
- [Images](#images)
@@ -126,6 +127,21 @@ Your renderers functions receive several arguments that will be very useful to m
126127
* `convertedCSSStyles` : conversion of the `style` attribute from CSS to react-native's stylesheet
127128
* `passProps` : various useful information : `groupInfo`, `parentTagName`, `parentIsText`...
128129

130+
### Making your custom component block or inline
131+
132+
By default, a custom renderer behaves like a block. So if you're rendering it between texts inside a `<p>`, you'll break your line.
133+
134+
If you want it to be inline, you can slightly change the way you declare it, like this :
135+
136+
```javascript
137+
renderers: {
138+
mytag: { renderer: myTagRenderer, wrapper: 'Text' }, // new way, is inline
139+
myothertag: myOtherTagRenderer // old regular way (still valid, behaves like a block)
140+
}
141+
```
142+
143+
> Note : the only values for `wrapper` are `Text` or `View` (default). Those don't represent the `<View>` and `<Text>` component of react-native but are instead used in the parser to prevent crashes and properly render every HTML markup.
144+
129145
### Lists prefixes
130146

131147
The default renderer of the `<ul>` and `<ol>` tags will either render a bullet or the count of your elements. If you wish to change this without having to re-write the whole list rendering implementation, you can use the `listsPrefixesRenderers` prop.

0 commit comments

Comments
 (0)