-
-
Notifications
You must be signed in to change notification settings - Fork 502
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: import emoji-mart dynamically like (#950) #1491
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
b6f27ab
to
931c5dd
Compare
931c5dd
to
a1a6cf9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice. I think we might want to also copy or reuse the pattern for loading the data. My guess is that it'll now it from a cdn, better to keep it isolated so we limit external dependencies
let emojiMart: typeof import("emoji-mart") | undefined; | ||
let emojiData: EmojiMartData | undefined; | ||
|
||
async function loadEmojiMart() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Decided to make both of these the same, and also made them Node.js safe
? (emojiDataModule.default as EmojiMartData) | ||
: (emojiDataModule as EmojiMartData); | ||
|
||
emojiMart.init({ data: emojiData }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this needs an await
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, wasn't clear that it was async in the docs https://github.com/missive/emoji-mart?tab=readme-ov-file#-emoji-component , but won't hurt to await
}> | ||
| undefined; | ||
|
||
// Temporary fix for https://github.com/missive/emoji-mart/pull/929 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fyi, the reason data was global and could be a promise would be to prevent duplicate loads when loadEmojiMart
is called twice in a row.
Didn't help readability and it might be a premature optimization so I'm ok with the new version as long as we don't see this causing any issues
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I can de-dupe easily. I'll pull that in.
This resolves the emoji-mart import dynamically just like what was done in #950 to resolve the same issue.