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); this.setState({ search: '' }); } render() { return (
); } } SearchBox.propTypes = { onSearch: PropTypes.func.isRequired };