diff --git a/packages/framework/esm-react-utils/src/Extension.tsx b/packages/framework/esm-react-utils/src/Extension.tsx index 6a64a4b88..b4af995df 100644 --- a/packages/framework/esm-react-utils/src/Extension.tsx +++ b/packages/framework/esm-react-utils/src/Extension.tsx @@ -41,7 +41,7 @@ export const Extension: React.FC = ({ const [domElement, setDomElement] = useState(); const { extension } = useContext(ComponentContext); const parcel = useRef(null); - const updatePromise = useRef | undefined>(); + const updatePromise = useRef>(Promise.resolve()); const rendering = useRef(false); useEffect(() => { @@ -136,7 +136,19 @@ export const Extension: React.FC = ({ parcel?.current?.getStatus() === "MOUNTED" && parcel.current.update ) { - updatePromise.current = parcel.current.update({ ...state }); + updatePromise.current = parcel.current + .update({ ...state }) + .catch((err) => { + // if we were trying to update but the component was unmounted + // while this was happening, ignore the error + if ( + !(err instanceof Error) || + !err.message.includes("minified message #32") || + parcel.current?.getStatus() === "MOUNTED" + ) { + throw err; + } + }); } } ); diff --git a/packages/framework/esm-react-utils/src/extensions.test.tsx b/packages/framework/esm-react-utils/src/extensions.test.tsx index c89c5f72d..42c62ed10 100644 --- a/packages/framework/esm-react-utils/src/extensions.test.tsx +++ b/packages/framework/esm-react-utils/src/extensions.test.tsx @@ -181,11 +181,14 @@ describe("ExtensionSlot, Extension, and useExtensionSlotMeta", () => { ); const metas = useExtensionSlotMeta("Box"); const wrapItem = useCallback( - (slot: React.ReactNode, extension: ExtensionData) => { + (slot: React.ReactNode, extension?: ExtensionData) => { return (

- {metas[getExtensionNameFromId(extension.extensionId)].code} + { + metas[getExtensionNameFromId(extension?.extensionId ?? "")] + .code + }

{slot}
@@ -196,7 +199,7 @@ describe("ExtensionSlot, Extension, and useExtensionSlotMeta", () => { return (
- + {wrapItem}