SolidJSS
SolidJSโ€ข12mo agoโ€ข
6 replies
snorbi

Calling a JSX event handler explicitly

How can I call an event handler explicitly?
const handleFocus = (e: FocusEvent) => {
        // perform some operation

        props.onFocus?.(e)
    }

It gives the compilation error:
This expression is not callable.
Not all constituents of type 'FocusEventHandlerUnion<HTMLInputElement, FocusEvent>' are callable.
Type 'BoundEventHandler<HTMLInputElement, FocusEvent, FocusEventHandler<HTMLInputElement, FocusEvent>>' has no call signatures.

Is it safe to simply check if it is a function, or not that simple?

Thanks
Was this page helpful?