Put in order · JavaScript and React course · Module 15: Patterns and Architecture

EventBus Listener Lifecycle

Arrange the stages of a listener's lifecycle in the useEventListener hook:

Items to put in order

  • Component unmounts
  • Cleanup function removes the listener (unsubscribe)
  • EventBus invokes the listener on each emit()
  • Component mounts in the React tree
  • useEffect registers the listener via eventBus.on()

You can check the correct answer by solving this task in the CodeWorlds game.