Skip to content

Instantly share code, notes, and snippets.

@RobAWilkinson
Created March 23, 2016 00:59
Show Gist options
  • Save RobAWilkinson/4c5925e05037ed24b2c6 to your computer and use it in GitHub Desktop.
Save RobAWilkinson/4c5925e05037ed24b2c6 to your computer and use it in GitHub Desktop.
import GridSelector from './grid-selector'
class Form extends React.Component
render() {
return (
<GridSelector
options={this.state.ageGroupOptions}
title='Age Groups?'
childClass='child'
wrapperClass='wrapper'
toggleClass='toggle'
handleSelect={this.handleSelect}
/>
)
}
}
export default class GridSelector extends Component {
render() {
return(
<div>
{this.props.title}
<div className={this.props.wrapperClass}>
{this.props.options.map((option, index) => {
console.log(option);
return (
<div
className={this.props.childClass + option.selected ? this.props.toggleClass : ''}
onClick={(e) => this.props.handleSelect(option, index)}
>
{option.label}
</div>
)
})}
</div>
</div>
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment