npm package diff

Package: @forge/react

Versions: 10.10.3 - 10.10.3-experimental-147ff14

File: package/out/hooks/useConfig.js

Index: package/out/hooks/useConfig.js
===================================================================
--- package/out/hooks/useConfig.js
+++ package/out/hooks/useConfig.js
@@ -1,9 +1,31 @@
 "use strict";
 Object.defineProperty(exports, "__esModule", { value: true });
 exports.useConfig = void 0;
-const useProductContext_1 = require("./useProductContext");
+const react_1 = require("react");
+const bridge_1 = require("@forge/bridge");
+const updateConfig = (setConfig) => {
+    bridge_1.view
+        .getContext()
+        .then((context) => {
+        setConfig(context?.extension.config);
+    })
+        .catch((err) => {
+        throw err;
+    });
+};
 const useConfig = () => {
-    const context = (0, useProductContext_1.useProductContext)();
-    return context?.extension.config;
+    const [config, setConfig] = (0, react_1.useState)(undefined);
+    (0, react_1.useEffect)(() => {
+        updateConfig(setConfig);
+    }, []);
+    (0, react_1.useEffect)(() => {
+        const sub = bridge_1.events.on('FORGE_CORE_MACRO_CONFIG_CHANGED', () => {
+            updateConfig(setConfig);
+        });
+        return () => {
+            void sub.then((subscription) => subscription.unsubscribe());
+        };
+    }, []);
+    return config;
 };
 exports.useConfig = useConfig;