How to declare events for your component at the type level for TSX?
Example
import { Host, c, useEvent } from "atomico";
type CustomDetail = { timestamp: number };
const MyComponent = c(
(): Host<{ onMyCustomEvent: CustomEvent<CustomDetail> }> => {
const dispatch = useEvent<CustomDetail>("MyCustomEvent");
return (
<host>
<button
onclick={() => {
dispatch({ timestamp: Date.now() });
}}
>Click</button>
</host>
);
}
);
Last updated
Was this helpful?
