Last active
May 23, 2023 16:14
-
-
Save kheuser/be44bdd9a71f1bb15fbf06aa22ccc211 to your computer and use it in GitHub Desktop.
Alternate colors on mapped React components
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
const componentName = () => { | |
const alternatingColor = ['#FCE389', '#F38181']; | |
return array.map((item, index) => ( | |
<SubComponent style={{color: alternatingColor[index % alternatingColor.length]}} /> | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment