File tree 2 files changed +15
-6
lines changed
2 files changed +15
-6
lines changed Original file line number Diff line number Diff line change 1
1
import React from 'react' ;
2
+ import PropTypes from 'prop-types' ;
2
3
3
4
import Styles from './Search.styles.scss' ;
4
5
import { useNetwork } from '../../state/network/Context' ;
5
6
6
- const Search = ( ) => {
7
- const { state, actions } = useNetwork ( ) ;
8
- const search = state . get ( 'search' ) ;
7
+ const Search = ( { name, value } ) => {
8
+ const { actions } = useNetwork ( ) ;
9
9
10
10
const handleInputChange = ( { target } ) => {
11
11
actions . updateSearch ( {
12
- name : search . name ,
12
+ name,
13
13
value : target . value ,
14
14
} ) ;
15
15
} ;
@@ -20,9 +20,18 @@ const Search = () => {
20
20
onChange = { handleInputChange }
21
21
placeholder = "Search by full URL"
22
22
type = "text"
23
- value = { search . value }
23
+ value = { value }
24
24
/>
25
25
) ;
26
26
} ;
27
27
28
+ Search . propTypes = {
29
+ name : PropTypes . string . isRequired ,
30
+ value : PropTypes . string ,
31
+ } ;
32
+
33
+ Search . defaultProps = {
34
+ value : '' ,
35
+ } ;
36
+
28
37
export default Search ;
Original file line number Diff line number Diff line change @@ -22,7 +22,7 @@ const FilterContainer = () => {
22
22
return (
23
23
< section className = { Styles [ 'filters-container' ] } >
24
24
< div className = { Styles [ 'filter-row' ] } >
25
- < Search />
25
+ < Search { ... state . get ( 'search' ) } />
26
26
</ div >
27
27
28
28
< div className = { Styles [ 'type-filter-row' ] } >
You can’t perform that action at this time.
0 commit comments