emoji-picker-react 4.5.8 → 4.5.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/context/PickerConfigContext.d.ts +1 -0
- package/dist/emoji-picker-react.cjs.development.js +25 -5
- package/dist/emoji-picker-react.cjs.development.js.map +1 -1
- package/dist/emoji-picker-react.cjs.production.min.js +1 -1
- package/dist/emoji-picker-react.cjs.production.min.js.map +1 -1
- package/dist/emoji-picker-react.esm.js +26 -6
- package/dist/emoji-picker-react.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/EmojiPickerReact.tsx +4 -1
- package/src/components/context/PickerConfigContext.tsx +18 -1
package/package.json
CHANGED
package/src/EmojiPickerReact.tsx
CHANGED
|
@@ -26,6 +26,8 @@ function EmojiPicker(props: PickerProps) {
|
|
|
26
26
|
|
|
27
27
|
// eslint-disable-next-line complexity
|
|
28
28
|
export default React.memo(EmojiPicker, (prev, next) => {
|
|
29
|
+
const prevCustomEmojis = prev.customEmojis ?? [];
|
|
30
|
+
const nextCustomEmojis = next.customEmojis ?? [];
|
|
29
31
|
return (
|
|
30
32
|
prev.emojiVersion === next.emojiVersion &&
|
|
31
33
|
prev.searchPlaceHolder === next.searchPlaceHolder &&
|
|
@@ -40,6 +42,7 @@ export default React.memo(EmojiPicker, (prev, next) => {
|
|
|
40
42
|
prev.height === next.height &&
|
|
41
43
|
prev.width === next.width &&
|
|
42
44
|
prev.searchDisabled === next.searchDisabled &&
|
|
43
|
-
prev.skinTonePickerLocation === next.skinTonePickerLocation
|
|
45
|
+
prev.skinTonePickerLocation === next.skinTonePickerLocation &&
|
|
46
|
+
prevCustomEmojis.length === nextCustomEmojis.length
|
|
44
47
|
);
|
|
45
48
|
});
|
|
@@ -17,7 +17,8 @@ const ConfigContext = React.createContext<PickerConfigInternal>(
|
|
|
17
17
|
);
|
|
18
18
|
|
|
19
19
|
export function PickerConfigProvider({ children, ...config }: Props) {
|
|
20
|
-
const
|
|
20
|
+
const mergedConfig = useSetConfig(config);
|
|
21
|
+
|
|
21
22
|
return (
|
|
22
23
|
<ConfigContext.Provider value={mergedConfig}>
|
|
23
24
|
{children}
|
|
@@ -25,6 +26,22 @@ export function PickerConfigProvider({ children, ...config }: Props) {
|
|
|
25
26
|
);
|
|
26
27
|
}
|
|
27
28
|
|
|
29
|
+
export function useSetConfig(config: PickerConfig) {
|
|
30
|
+
const [mergedConfig, setMergedConfig] = React.useState(() =>
|
|
31
|
+
mergeConfig(config)
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
React.useEffect(() => {
|
|
35
|
+
if (config.customEmojis?.length !== mergedConfig.customEmojis?.length) {
|
|
36
|
+
setMergedConfig(mergeConfig(config));
|
|
37
|
+
}
|
|
38
|
+
// not gonna...
|
|
39
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
40
|
+
}, [config.customEmojis?.length]);
|
|
41
|
+
|
|
42
|
+
return mergedConfig;
|
|
43
|
+
}
|
|
44
|
+
|
|
28
45
|
export function usePickerConfig() {
|
|
29
46
|
return React.useContext(ConfigContext);
|
|
30
47
|
}
|