Overview
The editor provides a typed event bus for communication between components. It’s a singleton instance built on the browser’s nativeCustomEvent API with events prefixed as
@react-email/editor:.
Dispatching events
Fire an event with a payload:Listening to events
Subscribe to events and clean up when done:on method returns an object with an unsubscribe function. Always unsubscribe in a
cleanup function to avoid memory leaks.
Built-in events
Adding custom events
Use TypeScript module augmentation to register custom events with full type safety:Event targets
By default, events are dispatched onwindow. You can scope events to a specific DOM element
using the target option: