1
1
import * as React from 'react' ;
2
2
3
+ import { PickerStyleTag } from './Stylesheet/stylesheet' ;
3
4
import { Reactions } from './components/Reactions/Reactions' ;
4
5
import { Body } from './components/body/Body' ;
5
6
import { ElementRefContextProvider } from './components/context/ElementRefContext' ;
@@ -8,12 +9,15 @@ import { useReactionsModeState } from './components/context/PickerContext';
8
9
import { Preview } from './components/footer/Preview' ;
9
10
import { Header } from './components/header/Header' ;
10
11
import PickerMain from './components/main/PickerMain' ;
12
+ import { compareConfig } from './config/compareConfig' ;
13
+ import { useOpenConfig } from './config/useConfig' ;
11
14
12
15
import { PickerProps } from './index' ;
13
16
14
17
function EmojiPicker ( props : PickerProps ) {
15
18
return (
16
19
< ElementRefContextProvider >
20
+ < PickerStyleTag />
17
21
< PickerConfigProvider { ...props } >
18
22
< ContentControl />
19
23
</ PickerConfigProvider >
@@ -24,13 +28,18 @@ function EmojiPicker(props: PickerProps) {
24
28
function ContentControl ( ) {
25
29
const [ reactionsDefaultOpen ] = useReactionsModeState ( ) ;
26
30
const [ renderAll , setRenderAll ] = React . useState ( ! reactionsDefaultOpen ) ;
31
+ const isOpen = useOpenConfig ( ) ;
27
32
28
33
React . useEffect ( ( ) => {
29
34
if ( ! renderAll ) {
30
35
setRenderAll ( true ) ;
31
36
}
32
37
} , [ renderAll ] ) ;
33
38
39
+ if ( ! isOpen ) {
40
+ return null ;
41
+ }
42
+
34
43
return (
35
44
< PickerMain >
36
45
< Reactions />
@@ -46,27 +55,4 @@ function ContentControl() {
46
55
}
47
56
48
57
// eslint-disable-next-line complexity
49
- export default React . memo ( EmojiPicker , ( prev , next ) => {
50
- const prevCustomEmojis = prev . customEmojis ?? [ ] ;
51
- const nextCustomEmojis = next . customEmojis ?? [ ] ;
52
- return (
53
- prev . emojiVersion === next . emojiVersion &&
54
- prev . reactionsDefaultOpen === next . reactionsDefaultOpen &&
55
- prev . searchPlaceHolder === next . searchPlaceHolder &&
56
- prev . searchPlaceholder === next . searchPlaceholder &&
57
- prev . defaultSkinTone === next . defaultSkinTone &&
58
- prev . skinTonesDisabled === next . skinTonesDisabled &&
59
- prev . autoFocusSearch === next . autoFocusSearch &&
60
- prev . emojiStyle === next . emojiStyle &&
61
- prev . theme === next . theme &&
62
- prev . suggestedEmojisMode === next . suggestedEmojisMode &&
63
- prev . lazyLoadEmojis === next . lazyLoadEmojis &&
64
- prev . className === next . className &&
65
- prev . height === next . height &&
66
- prev . width === next . width &&
67
- prev . style === next . style &&
68
- prev . searchDisabled === next . searchDisabled &&
69
- prev . skinTonePickerLocation === next . skinTonePickerLocation &&
70
- prevCustomEmojis . length === nextCustomEmojis . length
71
- ) ;
72
- } ) ;
58
+ export default React . memo ( EmojiPicker , compareConfig ) ;
0 commit comments