Skip to Content
DocumentationcomponentsDOMEvent

DOMEvent

Used for tracking DOM events. Wraps a child component and fires the specified event handler.

import { createTracker } from "@offlegacy/event-tracker"; const [Track] = createTracker({ DOMEvents: { onFocus: (params, context) => { // Handle focus event }, }, }); function App() { return ( <Track.Provider initialContext={{}}> <Track.DOMEvent type="onFocus" params={{...}}> <input /> </Track.DOMEvent> </Track.Provider> ); }

Props

  • type: DOMEventNames - Event name (e.g., onClick, onFocus)
  • params: unknown - Event parameters

Handling Renamed Event Props

The eventName prop allows you to specify a custom event handler name.
It allows you to dynamically specify the new event handler name, ensuring flexibility even when the handler names change.

function MyInput({ onInputFocus }: { onInputFocus?: () => void }) { return <input onFocus={onInputFocus} />; } function App() { return ( <Track.Provider initialContext={{}}> <Track.DOMEvent type="onFocus" params={{...}} eventName="onInputFocus"> <MyInput /> </Track.DOMEvent> </Track.Provider> ); }
Last updated on