ealush / emoji-picker-react

The most popular React Emoji Picker
https://ealush.com/emoji-picker-react/
MIT License
1.06k stars 173 forks source link

Forced type casting can cause errors. #300

Closed cateiru closed 1 year ago

cateiru commented 1 year ago

https://github.com/ealush/emoji-picker-react/blob/f5240a58a3aff969374c2ba67a77b7feaa19d141/src/dataUtils/asEmoji.ts#L3-L5

In this implementation, even if the emoji is undefined, it is coerced to the DataEmoji type. The return value is given as an argument to the emojiNames function, and if it is undefined or null, it can cause unexpected errors.

https://github.com/ealush/emoji-picker-react/blob/master/src/dataUtils/emojiSelectors.ts#L18-L20

The issue https://github.com/ealush/emoji-picker-react/issues/298 is presumed to be an example caused by that problem.

ealush commented 1 year ago

Should be fixed thanks to @cateiru

cateiru commented 1 year ago

Thank you for merging :bow: This issue has been resolved and will be closed.