more memoization
This commit is contained in:
+3
-6
@@ -103,9 +103,7 @@ export function ThemeProvider({
|
|||||||
})
|
})
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
return (
|
const value = React.useMemo<Alf>(
|
||||||
<Context.Provider
|
|
||||||
value={React.useMemo<Alf>(
|
|
||||||
() => ({
|
() => ({
|
||||||
themes,
|
themes,
|
||||||
themeName: themeName,
|
themeName: themeName,
|
||||||
@@ -128,10 +126,9 @@ export function ThemeProvider({
|
|||||||
setFontFamilyAndPersist,
|
setFontFamilyAndPersist,
|
||||||
fontScaleMultiplier,
|
fontScaleMultiplier,
|
||||||
],
|
],
|
||||||
)}>
|
|
||||||
{children}
|
|
||||||
</Context.Provider>
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
return <Context.Provider value={value}>{children}</Context.Provider>
|
||||||
}
|
}
|
||||||
|
|
||||||
export function useAlf() {
|
export function useAlf() {
|
||||||
|
|||||||
@@ -44,8 +44,6 @@ export function Text({
|
|||||||
...props
|
...props
|
||||||
}: React.PropsWithChildren<CustomTextProps>) {
|
}: React.PropsWithChildren<CustomTextProps>) {
|
||||||
const theme = useTheme()
|
const theme = useTheme()
|
||||||
const typography = theme.typography[type]
|
|
||||||
const lineHeightStyle = lineHeight ? lh(theme, type, lineHeight) : undefined
|
|
||||||
const {fonts} = useAlf()
|
const {fonts} = useAlf()
|
||||||
|
|
||||||
if (IS_DEV) {
|
if (IS_DEV) {
|
||||||
@@ -61,6 +59,9 @@ export function Text({
|
|||||||
}
|
}
|
||||||
|
|
||||||
const textProps = React.useMemo(() => {
|
const textProps = React.useMemo(() => {
|
||||||
|
const typography = theme.typography[type]
|
||||||
|
const lineHeightStyle = lineHeight ? lh(theme, type, lineHeight) : undefined
|
||||||
|
|
||||||
const flattened = StyleSheet.flatten([
|
const flattened = StyleSheet.flatten([
|
||||||
s.black,
|
s.black,
|
||||||
typography,
|
typography,
|
||||||
@@ -80,25 +81,24 @@ export function Text({
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const shared = {
|
return {
|
||||||
uiTextView: selectable && isIOS,
|
uiTextView: selectable && isIOS,
|
||||||
selectable,
|
selectable,
|
||||||
style: flattened,
|
style: flattened,
|
||||||
dataSet: Object.assign({tooltip: title}, dataSet || {}),
|
dataSet: Object.assign({tooltip: title}, dataSet || {}),
|
||||||
...props,
|
...props,
|
||||||
}
|
}
|
||||||
|
|
||||||
return shared
|
|
||||||
}, [
|
}, [
|
||||||
dataSet,
|
dataSet,
|
||||||
fonts.family,
|
fonts.family,
|
||||||
fonts.scaleMultiplier,
|
fonts.scaleMultiplier,
|
||||||
lineHeightStyle,
|
lineHeight,
|
||||||
props,
|
props,
|
||||||
selectable,
|
selectable,
|
||||||
style,
|
style,
|
||||||
|
theme,
|
||||||
title,
|
title,
|
||||||
typography,
|
type,
|
||||||
])
|
])
|
||||||
|
|
||||||
if (selectable && isIOS) {
|
if (selectable && isIOS) {
|
||||||
|
|||||||
Reference in New Issue
Block a user