aboutsummaryrefslogtreecommitdiff
path: root/vnext/src/components/SearchBox.js
blob: 612d860b792b78c07dcbde0a0fee47a35e092c41 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import React from 'react';
import PropTypes from 'prop-types';

export default class SearchBox extends React.Component {
    constructor(props) {
        super(props);
        this.state = {
            search: ''
        };
    }
    handleChange = (event) => {
        this.setState({
            search: event.target.value
        });
    }
    onSubmit = (event) => {
        event.preventDefault();
        this.props.onSearch(this.state.search);
    }
    render() {
        return (<form onSubmit={this.onSubmit}>
                  <input name="search" className="text"
                    placeholder="Search..." value={this.state.search} onChange={this.handleChange} />
                </form>);
    }
}

SearchBox.propTypes = {
    onSearch: PropTypes.func.isRequired
};