Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"type": "patch",
"area": "fix",
"workstream": "",
"comment": "Ensure theme is memoized for calls to useTheme",
"packageName": "@azure/communication-react",
"email": "2684369+JamesBurnside@users.noreply.github.com",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"type": "patch",
"area": "fix",
"workstream": "",
"comment": "Ensure theme is memoized for calls to useTheme",
"packageName": "@azure/communication-react",
"email": "2684369+JamesBurnside@users.noreply.github.com",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

import React, { createContext, useContext } from 'react';
import React, { createContext, useContext, useMemo } from 'react';
import { ThemeProvider, PartialTheme, Theme, getTheme, mergeThemes, mergeStyles } from '@fluentui/react';
import { lightTheme } from './themes';

Expand Down Expand Up @@ -63,8 +63,10 @@ const ThemeContext = createContext<Theme>(defaultTheme);
export const FluentThemeProvider = (props: FluentThemeProviderProps): JSX.Element => {
const { fluentTheme, rtl, children, /* @conditional-compile-remove(image-overlay) */ rootStyle } = props;

let fluentV8Theme: Theme = mergeThemes(defaultTheme, fluentTheme);
fluentV8Theme = mergeThemes(fluentV8Theme, { rtl });
const fluentV8Theme = useMemo(() => {
const mergedTheme = mergeThemes(defaultTheme, fluentTheme);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great catch!

return mergeThemes(mergedTheme, { rtl });
}, [fluentTheme, rtl]);

return (
<ThemeContext.Provider value={fluentV8Theme}>
Expand Down