Last active
September 9, 2019 23:47
-
-
Save adamhenson/fca7e0ef060a25b3aecd3454df5b409e to your computer and use it in GitHub Desktop.
Example Implementation of React.memo to Display a Set of Emojis
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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