Skip to content

Instantly share code, notes, and snippets.

@jamiejohnsonkc
Last active August 25, 2020 19:33
Show Gist options
  • Save jamiejohnsonkc/16e0854981f447e6f630803ab24e16fb to your computer and use it in GitHub Desktop.
Save jamiejohnsonkc/16e0854981f447e6f630803ab24e16fb to your computer and use it in GitHub Desktop.
Simple Dynamic List via mapping
/** @jsx jsx */
import { jsx } from 'theme-ui'
import React from 'react'
const list = ['a', 'b', 'c']
const SimpleUlList = () => (
<ul>
{list.map((item) => (
<li key={item}>{item}</li>
))}
</ul>
)
export default SimpleUlList
//If we would use the List as child component in another component, we could pass the list as props to it:
const mylist = ['a', 'b', 'c'];
const App = () => (
<SimpleList list={mylist} />
)
const SimpleList = ({ list }) => (
<ul>
{list.map(item => (
<li key={item}>{item}</li>
))}
</ul>
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment