aboutsummaryrefslogtreecommitdiff
path: root/vnext/src/ui/SearchBox.js
blob: 3f0b884b9617727ba26f629365f0e95068f77e89 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import React from 'react';
import { withRouter } from 'react-router-dom';
import { useFormState } from 'react-use-form-state';

/**
 * @param {{ pathname: string, onSearch: function, history: import('history').History }} props
 */
function SearchBox({ onSearch, history, pathname }) {
    let onSubmit = (event) => {
        event.preventDefault();
        onSearch(history, pathname, formState.values.search);
    };
    const [formState, { text }] = useFormState();
    return (
        <form onSubmit={onSubmit}>
            <input name="search" className="text"
                placeholder="Search..." value={formState.values.search} {...text('search')} />
        </form>
    );
}

export default withRouter(SearchBox);