EventHandlerProp
What an event attribute accepts: a plain handler, a [handler, data] tuple, or a listener object.
What an event attribute accepts: a plain handler, a [handler, data] tuple, or a listener object.
Use it to type a prop that is forwarded to an element's event attribute.
Import#
ts
import type { EventHandlerProp } from "@shadow-js/web";
Signature#
ts
type EventHandlerProp<T, E = Event> =
| EventHandler<T, E>
| BoundEventHandler<T, E>
| ListenerObject<T, E>
Examples#
ts
import type { EventHandlerProp } from "@shadow-js/web";
function SaveButton(props: { onPress?: EventHandlerProp<HTMLButtonElement, MouseEvent> }) {
return <button onClick={props.onPress}>Save</button>;
}