File tree Expand file tree Collapse file tree 1 file changed +8
-7
lines changed Expand file tree Collapse file tree 1 file changed +8
-7
lines changed Original file line number Diff line number Diff line change 1
1
/* @flow strict-local */
2
- import React from 'react' ;
2
+ import React , { useMemo } from 'react' ;
3
3
import type { Node } from 'react' ;
4
4
import { Image } from 'react-native' ;
5
5
import { createIconSet } from 'react-native-vector-icons' ;
@@ -18,19 +18,20 @@ const UnicodeEmoji = createIconSet(codeToEmojiMap);
18
18
type Props = $ReadOnly < { |
19
19
type : EmojiType ,
20
20
code : string ,
21
+ size ?: number ,
21
22
| } > ;
22
23
23
- const componentStyles = createStyleSheet ( {
24
- image : { width : 20 , height : 20 } ,
25
- } ) ;
26
-
27
24
export default function Emoji ( props : Props ) : Node {
28
- const { code } = props ;
25
+ const { code, size = 20 } = props ;
29
26
const imageEmoji = useSelector ( state =>
30
27
props . type === 'image' ? getAllImageEmojiByCode ( state ) [ props . code ] : undefined ,
31
28
) ;
29
+ const componentStyles = useMemo (
30
+ ( ) => createStyleSheet ( { image : { width : size , height : size } } ) ,
31
+ [ size ] ,
32
+ ) ;
32
33
if ( imageEmoji ) {
33
34
return < Image style = { componentStyles . image } source = { { uri : imageEmoji . source_url } } /> ;
34
35
}
35
- return < UnicodeEmoji name = { code } size = { 20 } /> ;
36
+ return < UnicodeEmoji name = { code } size = { size } /> ;
36
37
}
You can’t perform that action at this time.
0 commit comments