RecipesChapter 10: TypeScript and React

Typing Callbacks in React's Synthetic Event System

Recipe 10.6 from The TypeScript Cookbook

function onInput(event: React.SyntheticEvent) {
  event.preventDefault();
  // do something
}

const inp = <input type="text" onInput={onInput} />;
Open in TypeScript Playground →