diff --git a/packages/framework/esm-react-utils/src/openmrsComponentDecorator.tsx b/packages/framework/esm-react-utils/src/openmrsComponentDecorator.tsx index ab8f6212c..ea0c15d87 100644 --- a/packages/framework/esm-react-utils/src/openmrsComponentDecorator.tsx +++ b/packages/framework/esm-react-utils/src/openmrsComponentDecorator.tsx @@ -1,6 +1,6 @@ import React, { type ComponentType, type ErrorInfo, Suspense } from 'react'; import { I18nextProvider } from 'react-i18next'; -import { SWRConfig } from 'swr'; +import { SWRConfig, type SWRConfiguration } from 'swr'; import type {} from '@openmrs/esm-globals'; import { openmrsFetch } from '@openmrs/esm-api'; import { ComponentContext, type ComponentConfig, type ExtensionData } from './ComponentContext'; @@ -31,6 +31,7 @@ export interface ComponentDecoratorOptions { featureName: string; disableTranslations?: boolean; strictMode?: boolean; + swrConfig?: Partial>; } export interface OpenmrsReactComponentProps { @@ -98,9 +99,10 @@ export function openmrsComponentDecorator(userOpts: ComponentDecoratorOptions // TO-DO have a UX designed for when a catastrophic error occurs return
An error has occurred. Please try reloading the page.
; } else { + const swrConfig = { ...defaultSwrConfig, ...opts.swrConfig }; const content = ( - + {opts.disableTranslations ? ( @@ -120,7 +122,7 @@ export function openmrsComponentDecorator(userOpts: ComponentDecoratorOptions ); - + if (!opts.strictMode || !React.StrictMode) { return content; } else {