Skip to content

Commit

Permalink
chore: add comments to optimization functions
Browse files Browse the repository at this point in the history
  • Loading branch information
mateki0 committed Jan 13, 2024
1 parent 026999f commit 25a210f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/components/EmojiCategory.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ export const EmojiCategory = React.memo(

const [maxIndex, setMaxIndex] = React.useState(0)

// with InteractionManager we can show emojis after interaction is finished
// It helps with delay during category change animation
InteractionManager.runAfterInteractions(() => {
if (maxIndex === 0 && data.length) {
setMaxIndex(minimalEmojisAmountToDisplay)
Expand Down
2 changes: 2 additions & 0 deletions src/contexts/KeyboardProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ export const KeyboardProvider: React.FC<ProviderProps> = React.memo((props) => {
),
)

// On initial render we want to display only emojis that are visible right away after keyboard open
// Rest of emojis are loaded after user interaction with keyboard
const calculateMinimalEmojisAmountToDisplay = () => {
const defaultHeight = props.defaultHeight || defaultKeyboardContext.defaultHeight
const emojiSize = props.emojiSize || defaultKeyboardContext.emojiSize
Expand Down

0 comments on commit 25a210f

Please sign in to comment.