Skip to content

Instantly share code, notes, and snippets.

@adamhenson
Last active September 9, 2019 23:47
Show Gist options
  • Save adamhenson/fca7e0ef060a25b3aecd3454df5b409e to your computer and use it in GitHub Desktop.
Save adamhenson/fca7e0ef060a25b3aecd3454df5b409e to your computer and use it in GitHub Desktop.
Example Implementation of React.memo to Display a Set of Emojis
import React, { memo } from 'react';
const EmojiImages = ({ list }) => {
return (
<>
{list.emojis.map(current => (
<img alt="emoji" src={current} key={current} />
))}
</>
);
};
const areEqual = (prevProps, nextProps) => (prevProps.list.id === nextProps.list.id);
export default memo(EmojiImages, areEqual);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment