useEvent
Dispatch events from the webcomponent without referencing the context(this)
Syntax
const dispatchEvent = useEvent(myEvent, eventInit);Examples
import { useEvent } from "atomico";
function component() {
const dispatchEvent = useEvent("clickButton", {
bubbles: true,
composed: true,
});
return (
<host>
<button onclick={() => dispatchEvent()}>button</button>
</host>
);
}import { useEvent } from "atomico";
function component() {
const dispatchEvent = useEvent("clickButton", {
bubbles: true,
composed: true,
});
return (
<host>
<button onclick={() => {
const detail = "my-component"; // π
dispatchEvent(detail); // π
}}>button</button>
</host>
)cEvent customization
Recommended articles
How to declare events for your component at the type level for TSX?Last updated
Was this helpful?
