diff --git a/packages/react/src/primitives/message/MessageInProgress.tsx b/packages/react/src/primitives/message/MessageInProgress.tsx index 0cba17954..cfcaaa94d 100644 --- a/packages/react/src/primitives/message/MessageInProgress.tsx +++ b/packages/react/src/primitives/message/MessageInProgress.tsx @@ -4,8 +4,8 @@ import { Primitive } from "@radix-ui/react-primitive"; import { type ElementRef, forwardRef, - useMemo, ComponentPropsWithoutRef, + useEffect, } from "react"; import { useMessageContext } from "../../context/react/MessageContext"; @@ -20,10 +20,15 @@ export const MessagePrimitiveInProgress = forwardRef< >((props, ref) => { const { useMessageUtils } = useMessageContext(); - useMemo(() => { + // TODO make this more efficient + useEffect(() => { useMessageUtils .getState() .setInProgressIndicator(); + + return () => { + useMessageUtils.getState().setInProgressIndicator(null); + }; }, [useMessageUtils, props, ref]); return null;