import React from 'react' import PropTypes from 'prop-types' export default class Skins extends React.PureComponent { constructor(props) { super(props) this.state = { opened: false, } this.handleClick = this.handleClick.bind(this) } handleClick(e) { var skin = e.currentTarget.getAttribute('data-skin') var { onChange } = this.props if (!this.state.opened) { this.setState({ opened: true }) } else { this.setState({ opened: false }) if (skin != this.props.skin) { onChange(skin) } } } render() { const { skin } = this.props const { opened } = this.state const skinToneNodes = [] for (let i = 0; i < 6; i++) { const skinTone = i + 1 const selected = skinTone == skin skinToneNodes.push( ) } return
{skinToneNodes}
} } Skins.propTypes = { onChange: PropTypes.func, skin: PropTypes.number.isRequired, } Skins.defaultProps = { onChange: (() => {}), }