What is the TypeScript definition for the onFocusCapture event in React?

The right interface for onFocusCapture is FocusEvent

Please continue reading below to see how to use it or read my guide on using React events with TypeScript.

You can also go to the search page 🔍 to find another event.

Interface

interface FocusEvent<T = Element> extends SyntheticEvent<T, NativeFocusEvent> {
    relatedTarget: EventTarget | null;
    target: EventTarget & T;
}

Full example

import React, { FocusEvent } from 'react';

const InputComponent = () => {
  const handleFocusEvent = (e: FocusEvent<HTMLInputElement>) => {
    // Do something
  };

  return <input value="Some text" onFocusCapture={handleFocusEvent} />;
};

export default InputComponent;

Attributes that use FocusEvent:

Get notified about new tutorials

Join over 1,000 developers who receive React and JavaScript tutorials via email.

No spam. Unsubscribe at any time.