memoize emoji picker styles
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
import {useMemo} from 'react'
|
||||||
import {useColorScheme} from 'react-native'
|
import {useColorScheme} from 'react-native'
|
||||||
|
|
||||||
import {type EmojiPickerViewProps} from './EmojiPickerModule.types'
|
import {type EmojiPickerViewProps} from './EmojiPickerModule.types'
|
||||||
@@ -5,19 +6,23 @@ import EmojiPickerNativeView from './EmojiPickerView'
|
|||||||
|
|
||||||
const EmojiPicker = ({onEmojiSelected}: EmojiPickerViewProps) => {
|
const EmojiPicker = ({onEmojiSelected}: EmojiPickerViewProps) => {
|
||||||
const scheme = useColorScheme()
|
const scheme = useColorScheme()
|
||||||
|
const styles = useMemo(
|
||||||
|
() =>
|
||||||
|
({
|
||||||
|
flex: 1,
|
||||||
|
width: '100%',
|
||||||
|
backgroundColor: scheme === 'dark' ? '#000' : '#fff',
|
||||||
|
} as const),
|
||||||
|
[scheme],
|
||||||
|
)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<EmojiPickerNativeView
|
<EmojiPickerNativeView
|
||||||
onEmojiSelected={emoji => {
|
onEmojiSelected={emoji => {
|
||||||
onEmojiSelected(emoji)
|
onEmojiSelected(emoji)
|
||||||
}}
|
}}
|
||||||
style={[styles, {backgroundColor: scheme === 'dark' ? '#000' : '#fff'}]}
|
style={styles}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const styles = {
|
|
||||||
flex: 1,
|
|
||||||
width: '100%',
|
|
||||||
} as const
|
|
||||||
|
|
||||||
export default EmojiPicker
|
export default EmojiPicker
|
||||||
|
|||||||
Reference in New Issue
Block a user