Skip to main content

onChange

Description

Fires when a new value is selected in the control

Usage

onChange?: (ev: { value: string | number }) => void;

Parameters

The callback of the event takes an object with the following parameter:

  • value - (required) an id of the newly selected option or "" if the value is cleared

Example

function handleChange({ value }: { value: string | number }) {
console.log(value);
// id of a new selected option
}

<Select options={dataset} onChange={handleChange} />

Details

The handler function receives an object with an id of the newly selected option.

Related article: Catching the change of selected option