Download react-boilerplate/app/components/List/index.js from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 669 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/react-boilerplate/app/components/List/index.js
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/react-boilerplate/app/components/List/index.js
-
curl -L -o index.js https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/react-boilerplate/app/components/List/index.js
669 Bytes
| import React from 'react'; | |
| import PropTypes from 'prop-types'; | |
| import Ul from './Ul'; | |
| import Wrapper from './Wrapper'; | |
| function List(props) { | |
| const ComponentToRender = props.component; | |
| let content = <div />; | |
| // If we have items, render them | |
| if (props.items) { | |
| content = props.items.map(item => ( | |
| <ComponentToRender key={`item-${item.id}`} item={item} /> | |
| )); | |
| } else { | |
| // Otherwise render a single component | |
| content = <ComponentToRender />; | |
| } | |
| return ( | |
| <Wrapper> | |
| <Ul>{content}</Ul> | |
| </Wrapper> | |
| ); | |
| } | |
| List.propTypes = { | |
| component: PropTypes.elementType.isRequired, | |
| items: PropTypes.array, | |
| }; | |
| export default List; | |