Built-in Functions
Components come with a series of built-in functions that make it easier to interact with them.
Static Methods
These methods are called on the component class itself.
configuration
Get or set component configuration:
// Set configuration
MyComponent.configuration({
defaultValue: 'something',
options: { enabled: true }
});
// Get all configuration
const config = MyComponent.configuration();
// Get specific property
const value = MyComponent.configuration('defaultValue');template
Modify the HTML structure of a component without extending the class:
all
Get all instances of the component as an Artemis DOM object:
get
Get a specific instance by ID:
instances
Iterate over all component instances:
Instance Methods
These methods are available on each component instance.
setProps / setState
Update component properties or state:
forceRender
Force the component to re-render:
element
Get the component as an Artemis DOM instance:
content
Find a content element inside the component:
remove
Remove the component from the DOM:
instance
Find another instance of the same component type by ID:
parent
Get or set the parent component:
Rendering Methods
render
Define the component's HTML structure. Must be implemented:
Using Slots
Content placed inside component tags in HTML is rendered in <slot>:
Engine Interaction
Running Script Actions
Accessing Game State
Finding Elements
DOM Operations
Components use Artemis for DOM manipulation:
Complete Example
Related
Life Cycle - Component lifecycle methods
Built-in Properties - Component properties
Components Overview - Creating components
Last updated
Was this helpful?