Skip to content
These are temporary community docs. The official docs are in progress.Help improve them
Markless
Esc
↑↓navigate↵open⌘Jpreview
On this page

MARKLESS_EVENT_HANDLER_NOT_A_FUNCTION

An event prop like onClick gets a value instead of a function.

Error from the compiler, while it builds your .tsrx files.

What happened

An event prop needs a function. This one gets the result of an expression, which runs once during render.

Markless prints the message, the reason, and a suggestion:

MARKLESS_EVENT_HANDLER_NOT_A_FUNCTION: `<attributeName>={<source>}` passes the result of `<source>`, not a function. The expression would run once while rendering, and the click would receive a number.
An event prop compiles to a lazy handler symbol that runs on the browser event; only a function can be that handler.
Wrap it in a function, for example <attributeName>={() => <source>}.
https://markless.dev/errors/MARKLESS_EVENT_HANDLER_NOT_A_FUNCTION

Words in angle brackets change from case to case.

How to fix it

Wrap the expression in an arrow function.

<button onClick={() => count++}>Add</button>

Where it comes from

@markless/compiler raises this code. Source:

Read how to read a Markless error, or go back to all error codes.

Was this page helpful?