Skip to main content

onChange

Fires when an editable field reports a new value, before validation and save.

Usage

onChange?: (ev: {
key: string | number;
value: any;
input?: boolean;
update?: Record<string, any>;
}) => void;
FieldTypeDescription
keystring | numberChanged field key.
valueanyNew value.
inputbooleantrue while the user is still typing (raw input event); absent once the edit is committed (change/blur).
updateRecord<string, any>Map of all current unsaved values (the editing draft).

Example

import { Editor } from "@svar-ui/react-editor";

function onChange(ev) {
console.log(`field ${ev.key} changed to ${ev.value}`);
console.log("all unsaved changes", ev.update);
}

<Editor items={items} values={values} onChange={onChange} />;