Skip to content

Commit

Permalink
feat(ThemeProvider): add withoutModalsProvider prop (#5415)
Browse files Browse the repository at this point in the history
  • Loading branch information
Lukas742 authored Jan 11, 2024
1 parent 6c07525 commit a473036
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions packages/main/src/components/ThemeProvider/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,17 @@ const useStyles = createUseStyles(GlobalStyleClassesStyles, {

export interface ThemeProviderPropTypes {
children: ReactNode;
withoutModalsProvider?: boolean;
}

/**
* In order to use `@ui5/webcomponents-react` you have to wrap your application's root component into the ThemeProvider.
*
* __Note:__ Per default, the `ThemeProvider` adds another provider for the [Modals](https://sap.github.io/ui5-webcomponents-react/?path=/docs/user-feedback-modals--docs) API.
* If you don't use this, you can omit it by setting the prop `withoutModalsProvider` to `true`. (With v2.0, the `Modals` provider will be offered separately to reduce overhead)
*/
const ThemeProvider: FC<ThemeProviderPropTypes> = (props: ThemeProviderPropTypes) => {
const { children } = props;
const { children, withoutModalsProvider } = props;
useStyles();

useIsomorphicLayoutEffect(() => {
Expand All @@ -38,9 +45,7 @@ const ThemeProvider: FC<ThemeProviderPropTypes> = (props: ThemeProviderPropTypes

return (
<ReactJssThemeProvider theme={ThemingParameters}>
<I18nProvider>
<ModalsProvider>{children}</ModalsProvider>
</I18nProvider>
<I18nProvider>{withoutModalsProvider ? children : <ModalsProvider>{children}</ModalsProvider>}</I18nProvider>
</ReactJssThemeProvider>
);
};
Expand Down

0 comments on commit a473036

Please sign in to comment.