Skip to content

Commit

Permalink
[native] fix newer emojis crashing the app
Browse files Browse the repository at this point in the history
Summary:
As I was working on fixing the emoji keyboard colors I would encounter a bug sometimes when I rendered the emoji keyboard on the screen.

{F624622}

{F624621}

After some digging, I realized that this was being triggered because `rn-emoji-keyboard` uses an older unicode version so some of the newer emojis like (🫡) that were already selected from a different client (web) could not be found in the `keyedEmojiData`.

To fix this I made `keyedEmojiData[emoji]` optional so if a newer emoji is used instead of throwing an error the function will return undefined.

I have talked to the authors of the `rn-emoji-keyboard` library about this and they said that we should expect to see `rn-emoji-keyboard` use a newer unicode version in the coming months.

Test Plan:
Confirmed that the `alreadySelected` value looked like this and the crash no longer happens with emojis from a more recent unicode version

Logs:
```
 LOG  currentlySelected:
 LOG  ["red heart", undefined]
```

Reviewers: atul, kamil, ashoat

Reviewed By: ashoat

Subscribers: ashoat, tomek

Differential Revision: https://phab.comm.dev/D8435
  • Loading branch information
ginsueddy committed Jul 7, 2023
1 parent 8f2e057 commit 6de5244
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion native/components/emoji-keyboard.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ function EmojiKeyboard(props: Props): React.Node {

const [currentlySelected, setCurrentlySelected] = React.useState<
$ReadOnlyArray<string>,
>(() => alreadySelectedEmojis.map(emoji => keyedEmojiData[emoji].name));
>(() => alreadySelectedEmojis.map(emoji => keyedEmojiData[emoji]?.name));

const handleOnEmojiSelected = React.useCallback(
(emoji: EmojiSelection) => {
Expand Down

0 comments on commit 6de5244

Please sign in to comment.