Dispatch API
The dispatch method accepts two arguments:
dispatch(eventTarget, eventTuple);where:
| Parameter | Description |
|---|---|
eventTarget | The target element of the dispatched event, typically e.target. |
eventTuple | An array containing [eventName, eventPayload]. |
Example Usage
const eventPayload = {
id: '1234'
}
<button
onClick={(e) => dispatch(e.target, ['myCustomEventName', eventPayload])}
>
Click me!
</button>