A function cannot be stored in state
The message
MARKLESS_STATE_FUNCTION_UNSERIALIZABLE: state "<stateName>" holds a function, `<source>`, in its initial value. A function cannot be written into the page, so the browser would read a value that is not callable.
state() values are serialized into the page and the browser resumes from them without running the component body, so only data (strings, numbers, booleans, null, arrays and plain objects) survives the trip.
Keep the function outside state(): declare it in the component body or at module scope, and store only the data it needs, for example a name to pick it by.
https://markless.dev/errors/MARKLESS_STATE_FUNCTION_UNSERIALIZABLEWords in angle brackets change from case to case.
Why
state() values are serialized into the page and the browser resumes from them without running the component body, so only data (strings, numbers, booleans, null, arrays and plain objects) survives the trip.
Fix
Keep the function outside state(): declare it in the component body or at module scope, and store only the data it needs, for example a name to pick it by.