-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSearch.js
54 lines (31 loc) · 1.08 KB
/
Search.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
46
47
48
49
50
51
52
53
54
import React, { Component } from 'react';
import unsplash from '../apis/unsplash/unsplash'
class Search extends Component {
state={
SearchValue : '' ,
// searchData : []
}
onChangeValue=(event)=>{
this.setState({SearchValue:event.target.value}) ;
}
onSubmitForm=(event)=>{
event.preventDefault();
unsplash.get('/search/photos' ,{
params :{
query : this.state.SearchValue,
}
}).then((res)=>{
//this.setState({searchData: res.data.results});
this.props.ondata(res.data.results);
})
}
render() {
return (
<form onSubmit={this.onSubmitForm}>
<input onChange={this.onChangeValue} value={this.state.SearchValue} type="text" placeholder="Search keyword"/>
<input type="submit" value="search"/>
</form>
);
}
}
export default Search;