code: function listen(listener) {
      // TODO: Only use a single history listener. Otherwise we'll
      // end up with multiple concurrent calls to match.
      return history.listen(function (location) {
        if (state.location === location) {
          listener(null, state)
        } else {
          match(location, function (error, redirectLocation, nextState) {
            if (error) {
              listener(error)
            } else if (redirectLocation) {
              history.transitionTo(redirectLocation)
            } else if (nextState) {
              listener(null, nextState)
            } else {
              warning(
                false,
                'Location "%s" did not match any routes',
                location.pathname + location.search + location.hash
              )
            }
          })
        }
      })
    }
docs: This is the API for stateful environments. As the location
  changes, we update state and call the listener. We can also
  gracefully handle errors and redirects.