1 import React, {Component} from "react";
2 import PropTypes from "prop-types";
4 class SearchTerm extends Component {
5 constructor(props, context) {
10 this.handleChange = this.handleChange.bind(this);
11 this.handleAddTerm = this.handleAddTerm.bind(this);
12 this.handleRemoveTerm = this.handleRemoveTerm.bind(this);
16 const target = event.target;
17 const value = target.value;
23 handleAddTerm(event) {
27 handleRemoveTerm(event) {
28 const index = this.props.index;
29 this.props.onRemoveTerm(index);
34 <div key={this.props.index} className="search-term">
35 <input type="text" onChange={this.handleChange}/>
36 <button onClick={this.handleRemoveTerm}>Remove</button>
42 SearchTerm.propTypes = {
43 index: PropTypes.number.isRequired,
44 onAddTerm: PropTypes.func.isRequired,
45 onRemoveTerm: PropTypes.func.isRequired,
48 export default SearchTerm;