Update components
Updating Props, States, and Dispatch Requests.
Updating Props
export default function TextComponent({ props, view, update, context }) {
// Set default values for props
context.setDefault({ updatedOnce: false });
// Define click event to update props
const clickEvent = this.bind((props, view, item, event) => {
props.title = 'Headline updated in click event';
});
// Update props dynamically after a timeout
if (!props.updatedOnce) setTimeout(() => {
props.updatedOnce = true;
update({ title: "Updated through Timeout" });
//update(string|object|function|StratoxItem, object|function|StratoxItem);
}, 2000);
return `
<article class="relative card-1 border-bottom ingress">
<div class="wrapper md">
<h1 class="headline-1">${props.title}</h1>
<p>${props.description}</p>
<button class="button bg-primary" onclick="${clickEvent}">Change headline</button>
</div>
</article>
`;
}Updating States
Dispatching Requests
Last updated