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

The right interface for onAnimationStart is AnimationEvent

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 AnimationEvent<T = Element> extends SyntheticEvent<T, NativeAnimationEvent> {
    animationName: string;
    elapsedTime: number;
    pseudoElement: string;
}

Full example

import React, { AnimationEvent } from 'react';

const App = () => {
  const handleAnimationEvent = (e: AnimationEvent<HTMLDivElement>) => {
    // Do something
  };

  return <div onAnimationStart={handleAnimationEvent}>{/** Some code */}</div>;
};

export default App;

Attributes that use AnimationEvent:

Get notified about new tutorials

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

No spam. Unsubscribe at any time.

© 2022 Felix Gerschau. All rights reserved.