Element API
How to use the Element API to manually control a component and call methods on it.
Description
Every Wompo Component will be rendered in the DOM as a Web Component, so it'll be accessible by your scripts. In this guide we will explore what methods you can call and which properties you can access.
Methods
Every element exposes the followig methods:
<b>requestRender()</b>- If called, it will start the rendering process of the component.<b>onDisconnected()</b>- Should not be called directly: it's a callback function that you can override, and will be executed whenever the component is disconnected from the DOM.<b>updateProp(propName, newValue)</b>- It will update a prop of the component and automatically ask to re-render it if the new value differs from the previous one. The first parameter is the name of the prop you want to update, and the second is the new value you want to set on it.
If you used the
Properties
Every element exposes the followig properties:
<b>props</b>- The object containing all the props of the component.<b>hooks</b>- The list of hooks that the component has. You can access this property but we strongly recommend to not modify any of them. It is exposed only so that you can add your own hooks. See theuseHook hook to know more.
If you used the
Dynamic Tags - Wompo APIs
Use a runtime value as the tag name of an element inside an html template, including components, built-in tags, and conditional expressions.
html API - Wompo APIs
The html function lets you build your component's HTML as a string, and get the dynamic parts of it.