Skip to content

Commit

Permalink
more memo
Browse files Browse the repository at this point in the history
  • Loading branch information
stipsan committed Nov 22, 2024
1 parent 7a0d08b commit 2f91a31
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
8 changes: 5 additions & 3 deletions packages/sanity/src/core/studio/StudioThemeProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import {LayerProvider, ThemeProvider} from '@sanity/ui'
import {type RootTheme} from '@sanity/ui/theme'
import {type ReactNode} from 'react'
import {memo, type ReactNode} from 'react'
import {ColorSchemeSetValueContext, ColorSchemeValueContext} from 'sanity/_singletons'

import {defaultTheme, type StudioTheme} from '../theme'
Expand All @@ -28,7 +28,9 @@ function getThemeValues(theme: StudioTheme): RootTheme {
}

/** @internal */
export function StudioThemeProvider({children}: StudioThemeProviderProps) {
export const StudioThemeProvider = memo(function StudioThemeProvider({
children,
}: StudioThemeProviderProps) {
const theme = useActiveWorkspace().activeWorkspace.theme

if (theme.__legacy) {
Expand All @@ -49,4 +51,4 @@ export function StudioThemeProvider({children}: StudioThemeProviderProps) {
<LayerProvider>{children}</LayerProvider>
</ThemeProvider>
)
}
})
6 changes: 3 additions & 3 deletions packages/sanity/src/core/user-color/provider.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {type ReactElement, type ReactNode, useMemo} from 'react'
import {memo, type ReactElement, type ReactNode, useMemo} from 'react'
import {UserColorManagerContext} from 'sanity/_singletons'

import {useColorSchemeValue} from '../studio'
Expand All @@ -12,7 +12,7 @@ export interface UserColorManagerProviderProps {
}

/** @internal */
export function UserColorManagerProvider({
export const UserColorManagerProvider = memo(function UserColorManagerProvider({
children,
manager: managerFromProps,
}: UserColorManagerProviderProps): ReactElement {
Expand All @@ -25,4 +25,4 @@ export function UserColorManagerProvider({
return (
<UserColorManagerContext.Provider value={manager}>{children}</UserColorManagerContext.Provider>
)
}
})

0 comments on commit 2f91a31

Please sign in to comment.