toEventHandler() function
Converts a state callback function to an event handler function.
Syntax
toEventHandler(stateCallback, isValid)
Parameters
-
stateCallback
A function with the signature of a state callback. -
isValid
optional
A validity state value to be assigned to aValidationResult
object passed tostateCallback
.
Default:false
.
Return value
A function with the signature of an event listener.
Description
This helper function is intended to be used with apply effect functions in case the effect is needed to be performed as an event listener.
import { toEventHandler, applyBox } from 'isomorphic-validation/ui';
const [, showMsg] = applyBox({ false: { value: 'Invalid data.' } });
// ...
form.addEventListener('focusout', toEventHandler(showMsg));
Implementation: to-event-handler.js.