Please continue reading below to see how to use it or read my guide on using React's events with TypeScript.
Composition events get triggered when the user enters text.
The event allows you to access that data through the "data" field.
interface CompositionEvent<T = Element> extends SyntheticEvent<T, NativeCompositionEvent> {
data: string;
}
import React, { CompositionEvent } from 'react';
const InputComponent = () => {
const handleCompositionEvent = (e: CompositionEvent<HTMLInputElement>) => {
// Do something
};
return <input value="Some text" onCompositionStartCapture={handleCompositionEvent} />;
};
export default InputComponent;