Course contentsShow
← React
Lesson 2359 of 2,39651. TypeScript with React BasicsFree lesson

The React.SyntheticEvent Base Type

Understand React's cross-browser event wrapper and when to use the base SyntheticEvent type vs specific subtypes.

The React.SyntheticEvent Base Type

What you'll learn: How React's generic SyntheticEvent type works and when to use it instead of specific event types.

The Cross-Browser Wrapper

You've been using specific event types like React.MouseEvent and React.ChangeEvent. These are all subtypes of React.SyntheticEvent, React's cross-browser wrapper around native browser events. React normalizes events so they work identically across browsers—you get the same properties and methods whether your user is on Chrome, Firefox, or Safari.

Think of SyntheticEvent as the parent class in a family tree. Just as MouseEvent and ChangeEvent inherit from it, you can type handlers with the base type when you don't need specific event properties.

When to Use the Base Type

Use React.SyntheticEvent when:

  • You're writing a generic event handler that doesn't care about event-specific properties
  • You're accepting multiple event types in one handler
  • You only need common properties like preventDefault() or stopPropagation()
function handleGenericEvent(event: React.SyntheticEvent) {
  event.preventDefault();
  // This works for any event type
}

// Accepts any event from any element
function logEvent(event: React.SyntheticEvent<HTMLElement>) {
  console.log("Event fired on:", event.currentTarget);
}

Use specific subtypes (MouseEvent, ChangeEvent, etc.) when you need properties unique to that event, like event.clientX for mouse events or event.target.value for change events.

Key Takeaway: React.SyntheticEvent is React's unified base event type that provides cross-browser consistency—use it for generic handlers, but prefer specific subtypes when you need event-specific properties.