Last active
June 10, 2020 17:24
-
-
Save tadjohnston/15d42e8bb7eaa8277444adef51f0576b to your computer and use it in GitHub Desktop.
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, { Component } from 'react' | |
import PropTypes from 'prop-types' | |
import Baz from 'baz' | |
class Foo extends Component { | |
static propTypes = { | |
list: PropTypes.array, | |
} | |
static defaultProps = { | |
list: '', | |
} | |
items = (list) => { | |
const filteredList = list | |
.filter(i => i !== null) | |
.map(item => ({ bar: item.baz })) | |
return filteredList.map((item, index) => ( | |
<Baz | |
key={index} | |
bar={item.bar} | |
something={item.bar} | |
/> | |
)) | |
} | |
render() { | |
const { list } = this.props | |
return ( | |
<div> | |
{list && ( | |
<div> | |
{`Count is ${this.props.count} for items: `} {this.items(list)} | |
</div> | |
)} | |
{!list && ( | |
{`Count is ${this.props.count} for items: `} n/a | |
)} | |
</div> | |
) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment