docs: function listenBeforeLeavingRoute(route, hook) {
      // TODO: Warn if they register for a route that isn't currently
      // active. They're probably doing something wrong, like re-creating
      // route objects on every location change.
      const routeID = getRouteID(route)
      let hooks = RouteHooks[routeID]
  
      if (!hooks) {
        let thereWereNoRouteHooks = !hasAnyProperties(RouteHooks)
  
        RouteHooks[routeID] = [ hook ]
  
        if (thereWereNoRouteHooks) {
          // setup transition & beforeunload hooks
          unlistenBefore = history.listenBefore(transitionHook)
  
          if (history.listenBeforeUnload)
            unlistenBeforeUnload = history.listenBeforeUnload(beforeUnloadHook)
        }
      } else {
        if (hooks.indexOf(hook) === -1) {
          warning(
            false,
            'adding multiple leave hooks for the same route is deprecated; manage multiple confirmations in your own code instead'
          )
  
          hooks.push(hook)
        }
      }
  
      return function () {
        const hooks = RouteHooks[routeID]
  
        if (hooks) {
          const newHooks = hooks.filter(item => item !== hook)
  
          if (newHooks.length === 0) {
            removeListenBeforeHooksForRoute(route)
          } else {
            RouteHooks[routeID] = newHooks
          }
        }
      }
    }