🧩VirtualDOM
Atomico's virtualDOM is designed to enhance the use of webcomponents.
Syntax
JSX
Atomico supports jsx-runtime, alternatively you can import the h
function to declare manual of the JSX pragma, eg:
Template String
Atomico supports the use of template-string thanks to the use of the package htm.
Return rule
An important rule of Atomico's virtualDOM is that every webcomponent must return the <host/>
tag since it represents the state of the webcomponent's DOM, such as:
Enable the use of the shadowDOM by declaring the
shadowDom
property.Association of events, attributes or properties.
Template of the webcomponent.
Template
Event Association
Atomico considers that a property must be associated as an event if it is of the function type and begins with the prefix 'on', eg:
Simple lists
Lists with keys
the key property can receive values of the type of any type that allows generating a reference to the node, eg:
Node references
A technique inherited from React, it allows obtaining the reference of the node to which the Ref object is associated through the ref property, example:
The references must be immutable objects, to create it there is the useRef hook that creates a reference for each instance of the webcomponent.
shadowDom property
This property allows you to declare the use of the shadowDom, eg:
Method association
You can declare a method by declaring a function in the host tag without using the prefix on in its name, eg:
If when creating or updating the DOM it does not detect the use of the property, it will be associated as a method of this, thus allowing it to be accessed from the DOM, eg:
To access the DOM safely wait for the resolution of the updated property created by the render cycle.
Last updated