Skip to main content



The useEvent React Hook allows us to register a new callback function to the passed Event.

useEvent(MY_EVENT, () => {
// This is a 'callback function' which gets called when ever the EVENT gets triggered

The advantage of using this Hook instead of the on method in a React Component, is that the registered callback function gets automatically unregistered whenever the Component unmounts.

๐Ÿ”ด Example#

Live Editor

๐ŸŸฆ Typescript#

useEvent is almost 100% typesafe.

๐Ÿ“ญ Props#

eventEvent (E)Event to which the passed callback function gets applied.Yes
callbackEventCallbackFunction<E['payload']>Callback Function that gets applied to the passed EventYes
keystring | numberKey/Name of created Observer. Mainly thought for Debugging.No
agileInstanceAgileTo which Agile Instance the Event get bound. Gets autodetect!No

๐Ÿ“„ Return#

useEvent returns nothing.

Last updated on