Skip to content

Instantly share code, notes, and snippets.

@kheuser
Last active May 23, 2023 16:14
Show Gist options
  • Save kheuser/be44bdd9a71f1bb15fbf06aa22ccc211 to your computer and use it in GitHub Desktop.
Save kheuser/be44bdd9a71f1bb15fbf06aa22ccc211 to your computer and use it in GitHub Desktop.
Alternate colors on mapped React components
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