Memoize usePalette (#2201)
parent
b1f9454f1d
commit
0e3218db7d
|
@ -1,3 +1,4 @@
|
|||
import {useMemo} from 'react'
|
||||
import {TextStyle, ViewStyle} from 'react-native'
|
||||
import {useTheme, PaletteColorName, PaletteColor} from '../ThemeContext'
|
||||
|
||||
|
@ -15,7 +16,9 @@ export interface UsePaletteValue {
|
|||
icon: TextStyle
|
||||
}
|
||||
export function usePalette(color: PaletteColorName): UsePaletteValue {
|
||||
const palette = useTheme().palette[color]
|
||||
const theme = useTheme()
|
||||
return useMemo(() => {
|
||||
const palette = theme.palette[color]
|
||||
return {
|
||||
colors: palette,
|
||||
view: {
|
||||
|
@ -49,4 +52,5 @@ export function usePalette(color: PaletteColorName): UsePaletteValue {
|
|||
color: palette.icon,
|
||||
},
|
||||
}
|
||||
}, [theme, color])
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue