useCommittableValue Function

Custom React hook that provides to commit or cancel value changes by editor using Enter or Escape keys.

Example usage:

function MyValueEditor({ initialValue, ...editorProps }: Props) { const { value, onChange, onKeyDown, commit, cancel } = useCommittableValue({ initialValue, onCommit: (newValue) => { // commit new value } onCancel: () => { // restore to initial value or close editor } }) return <div onKeyDown={onKeydown}> <Editor {...editorProps} value={value} onChange={onChange} commit={commit} cancel={cancel} /> </div> }

useCommittableValue(__namedParameters: UseCommittableValueProps): Pick<EditorProps, "commit" | "value" | "onChange" | "cancel"> & { onKeydown: (e: React.KeyboardEvent) => void }

Parameter Type Description
__namedParameters UseCommittableValueProps  

Returns - Pick<EditorProps, "commit" | "value" | "onChange" | "cancel"> & { onKeydown: (e: React.KeyboardEvent) => void }

Defined in

Last Updated: 15 May, 2026