Architecture
important
Consumers of this library can benefit greatly from understanding the basic data flow model to leverage its capabilities. Features such as props will touch on different areas of this data flow.
#
Hello World!Let's start with a simple example:
This looks pretty simple. But what exactly is happening under the hood? As laid out in the โReinvent the Wheel page, we need some logic to translate the DOM into a structure easily translatable into native elements and support all the features mentioned in the referred page. This data structure is called the Transient Render Tree (โTRE), see figure below.
#
Data FlowWe can roughly split the transformations from an HTML string to a React tree in 3 steps:
HTML parsing. In this step, the HTML code is parsed to form a DOM tree. This step is performed by the โ
htmlparser2
library.โTRT Construction. In this step, the DOM tree is transformed in a TRT. Each node of this tree is referred to as a Transient Node (TNode) which has React-Native compatible styles. This step is performed by โ
@native-html/transient-render-engine
module.Transient Render Tree Rendering. In this step, the โTRT is transformed in a React render tree (VDOM). TNodes are passed to internal and custom renderers.
For more information on โTRT construction, see โTransient Render Engine and โCSS Processing pages.