Rendering
Composite Rendering Architecture#
When you consume the โRenderHTML component, you are actually using three distinct components. So this (implicit composite):
is equivalent to this (explicit composite):
You can actually use the explicit composite architecture by importing those components:
tip
The great benefit of using explicitly this composite rendering architecture is that the engine and configuration can be put near the top of your App to factor the cost of instantiating the engine. This is especially usefull for apps which will render hundreds to thousands of small snippets such as chat apps.
Note that props of the โRenderHTML component are split between the three layers of the rendering architecture:
Will take all โ
RenderHTMLprops pertaining to the โTransient Render Engine layer such as โcustomHTMLElementModels, โclassesStyles(all styling props) and DOM related such as โdomVisitors, โselectDomRoot... See โTRenderEngineConfigfor a complete reference.Will take all โ
RenderHTMLprops pertaining to the โRendering layer such as โrenderers, โrenderersProps, โcomputeEmbeddedMaxWidth, ... See โRenderHTMLConfigfor a complete reference.Will take all โ
RenderHTMLprops pertaining to the document such as โsource, โonTTreeChange, โcontentWidth. See โRenderHTMLSourcePropsfor a complete reference.
Default TNode Renderers#
Each node of the โTRT is translated to a React component in the TNodeRenderer component. Internally, TNodeRenderer will map each type of TNode to its dedicated component. TDocumentRenderer for TDocument nodes, TBlockRenderer for โTBlock nodes, TPhrasingRenderer for โTPhrasing nodes and TTextRenderer for โTText nodes.
Under the hood, TPhrasingRenderer and TTextRenderer use React Native โText wrapper component, while TBlockRenderer and TDocumentRenderer use React Native โView wrapper component.
Each renderer will pass styles provided by its underlying TNode to its React Native wrapper. Children are rendered thanks to the TChildrenRenderer component.
Custom Renderers#
Custom renderers are components defined for specific tags. They can be specified with the โrenderers prop, which is a mapping of tags with the corresponding components. See the โCustom Rendering page. Also note that props targeting those renderers can be passed to a custom renderer via the โrenderersProps prop, which is a mapping of tag names with its corresponding props. Those props can be consumed from the custom renderer via useRendererProps hook.
Internal Renderers#
Some tags such as โ<img>, โ<ol>, โ<ul> and โ<a> are handled by special renderers, namely internal renderers. Those renderers can be thought of as "internal custom renderers". See the โImages, โLists and โAnchors corresponding pages.