handleValidationError
handleValidationError(
setFieldErrors,onOtherError?): (error) =>void
Defined in: react/src/validation.ts:190
React hook-friendly error handler that extracts validation errors. Returns a callback suitable for onError handlers.
Parameters
Section titled “Parameters”setFieldErrors
Section titled “setFieldErrors”(errors) => void
onOtherError?
Section titled “onOtherError?”(error) => void
Returns
Section titled “Returns”(error) => void
Example
Section titled “Example”const [fieldErrors, setFieldErrors] = useState<FieldErrors>({})
const { mutate } = useActorMutation({ functionName: "transfer", onError: handleValidationError(setFieldErrors),})
// In JSX<input name="to" />{fieldErrors.to && <span className="error">{fieldErrors.to}</span>}