useOn() / useOnDocument() / useOnWindow()
useOnWindow() to programmatically set up listeners on host elements. This is useful when you are creating custom APIs and don't have access to place these events in the JSX or if the events are not known ahead of time, such as if they are created based on component props.
The example on the right shows how to use
useOn() method. Duplicate the code to explore how to use
useOnWindow() and how they behave differently.