BoundEventHandler
Handler and data as a tuple: [(data, event) => void, data].
Handler and data as a tuple: [(data, event) => void, data]. The data is passed as the first
argument, the event second.
The handler is declared with method-style (bivariant) parameters, so a handler that annotates its
data type is accepted at JSX sites, where the data type is unknown.
Import#
ts
import type { BoundEventHandler } from "@shadow-js/web";
Signature#
ts
type BoundEventHandler<T, E = Event, D = unknown> = [BoundHandlerFunction<T, E, D>, D]
Examples#
ts
import type { BoundEventHandler } from "@shadow-js/web";
interface Row {
id: number;
}
const select = (id: number, extend: boolean) => console.log(id, extend);
const onRowClick: BoundEventHandler<HTMLButtonElement, MouseEvent, Row> = [
(row, event) => select(row.id, event.shiftKey),
{ id: 7 },
];