import classnames from 'classnames'; import React from 'react'; import AddMini from '../icons/AddMini'; import RemoveMini from '../icons/RemoveMini'; const METHODS_TO_BIND = [ 'getTextboxes', 'handleTextboxChange' ]; export default class TextboxRepeater extends React.Component { constructor() { super(); METHODS_TO_BIND.forEach((method) => { this[method] = this[method].bind(this); }); } getTextboxes() { let textboxes = this.props.textboxes.map((textbox, index) => { let addButton = ( ); let removeButton = null; if (index > 0) { removeButton = ( ); } let inputClasses = classnames('textbox', { 'is-fulfilled': textbox.value && textbox.value !== '' }); return (
{removeButton} {addButton}
); }); return textboxes; } handleTextboxChange(index, event) { this.props.handleTextboxChange(index, event.target.value); } render() { return (
{this.getTextboxes()}
); } }