Skip to content

Commit a1a6cf9

Browse files
committed
fix: import emoji-mart dynamically like (#950)
1 parent 6f230c2 commit a1a6cf9

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

packages/react/src/components/Comments/EmojiMartPicker.tsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// From https://github.com/missive/emoji-mart/blob/main/packages/emoji-mart-react/react.tsx
22
import React, { useEffect, useRef } from "react";
3-
import { Picker } from "emoji-mart";
3+
4+
// Temporary fix for https://github.com/missive/emoji-mart/pull/929
5+
let emojiMart: typeof import("emoji-mart") | undefined;
46

57
// eslint-disable-next-line @typescript-eslint/no-explicit-any
68
export default function EmojiPicker(props: any) {
@@ -12,7 +14,14 @@ export default function EmojiPicker(props: any) {
1214
}
1315

1416
useEffect(() => {
15-
instance.current = new Picker({ ...props, ref });
17+
(async () => {
18+
if (!emojiMart) {
19+
// load dynamically because emoji-mart doesn't specify type: module and breaks in nodejs
20+
emojiMart = await import("emoji-mart");
21+
}
22+
23+
instance.current = new emojiMart.Picker({ ...props, ref });
24+
})();
1625

1726
return () => {
1827
instance.current = null;

0 commit comments

Comments
 (0)