diff --git a/.changeset/proud-rings-attend.md b/.changeset/proud-rings-attend.md new file mode 100644 index 0000000..c983f55 --- /dev/null +++ b/.changeset/proud-rings-attend.md @@ -0,0 +1,5 @@ +--- +"@spur.us/monocle-react": patch +--- + +Fix refresh return type in `MonocleContextType` diff --git a/packages/monocle-react/src/contexts/MonocleProvider.tsx b/packages/monocle-react/src/contexts/MonocleProvider.tsx index 30ace07..e1db9ae 100644 --- a/packages/monocle-react/src/contexts/MonocleProvider.tsx +++ b/packages/monocle-react/src/contexts/MonocleProvider.tsx @@ -9,9 +9,10 @@ import React, { import { withMaxAllowedInstancesGuard } from '../utils'; import { MonocleProviderProps } from '../types'; import { DOMAIN } from '../constants'; + interface MonocleContextType { assessment: string | undefined; - refresh: () => void; + refresh: () => Promise; isLoading: boolean; error: Error | null; } @@ -61,10 +62,9 @@ const MonocleProviderComponent: React.FC = ({ try { setIsLoading(true); setError(null); - + if (window.MCL) { await window.MCL.refresh(); - setIsLoading(false); } else { throw new Error('MCL object not found on window'); } @@ -108,7 +108,7 @@ const MonocleProviderComponent: React.FC = ({ if (!assessment) { initializeMCL(); } - + // Cleanup function to reset callback on unmount return () => { if (window.MCL) {