-
Notifications
You must be signed in to change notification settings - Fork 0
/
SearchBar.js
45 lines (39 loc) · 1.05 KB
/
SearchBar.js
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import './SearchBar.css';
import React from 'react';
class SearchBar extends React.Component {
state = { term: this.props.defaultTerm };
onInputChange = (event) => {
this.setState({ term: event.target.value });
};
onFormSubmit = (event) => {
event.preventDefault();
this.props.onFormSubmit(this.state.term);
};
render() {
return (
<div className="search-bar ui segment">
<form onSubmit={this.onFormSubmit} className="ui form">
<div className="field">
<h2 className="ui header">Video Search</h2>
<div>
<input
id="search-input"
type="text"
value={this.state.term}
onChange={this.onInputChange}
/>
<button
className="ui youtube button"
type="submit"
onClick={this.onFormSubmit}
>
Search
</button>
</div>
</div>
</form>
</div>
);
}
}
export default SearchBar;