@forge/react
11.18.0-next.011.18.0-next.1
out/router/hooks/useLocation.js+
out/router/hooks/useLocation.jsNew file+19
Index: package/out/router/hooks/useLocation.js
===================================================================
--- package/out/router/hooks/useLocation.js
+++ package/out/router/hooks/useLocation.js
@@ -0,0 +1,19 @@
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.useLocation = void 0;
+const react_1 = require("react");
+const RouterContext_1 = require("../components/RouterContext");
+/**
+ * This hook returns the current location object, which contains information about the current URL. It updates automatically when the user navigates to a different route.
+ * It must be used within a Router component.
+ *
+ * @see [useLocation](https://developer.atlassian.com/platform/forge/ui-kit/hooks/use-location/) in UI Kit documentation for more information
+ */
+const useLocation = () => {
+ const context = (0, react_1.useContext)(RouterContext_1.RouterContext);
+ if (!context) {
+ throw new Error('useLocation must be used within a Router component');
+ }
+ return context.location;
+};
+exports.useLocation = useLocation;