Skip to Content
DocumentationcomponentsClick

Click

A specialized version of DOMEvent for click events (type="onClick").

import { createTracker } from "@offlegacy/event-tracker"; const [Track] = createTracker({ DOMEvents: { onClick: (params, context) => { // Handle click event }, }, }); function App() { return ( <Track.Provider initialContext={{}}> <Track.Click params={{ buttonId: "submit" }}> <button>Submit</button> </Track.Click> </Track.Provider> ); }

Props

  • params: unknown - Click event parameters

Handling Renamed Click Event Prop

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

function MyButton({ onButtonClick }: { onButtonClick?: () => void }) { return <button onClick={onButtonClick} />; } function App() { return ( <Track.Provider initialContext={{}}> <Track.Click type="onFocus" params={{...}} eventName="onButtonClick"> <MyButton /> </Track.Click> </Track.Provider> ); }
Last updated on