-
Notifications
You must be signed in to change notification settings - Fork 0
/
SearchContainer.js
77 lines (72 loc) · 2.14 KB
/
SearchContainer.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import React, { Component } from 'react';
import {
Text,
View,
TouchableOpacity,
} from 'react-native';
import SearchBar from 'react-native-searchbar';
const items = [
1337,
'janeway',
{
lots: 'of',
different: {
types: 0,
data: false,
that: {
can: {
be: {
quite: {
complex: {
hidden: [ 'gold!' ],
},
},
},
},
},
},
},
[ 4, 2, 'tree' ],
];
export default class SearchContainer extends Component {
constructor(props) {
super(props);
this.state = {
items,
results: []
};
this._handleResults = this._handleResults.bind(this);
}
_handleResults(results) {
this.setState({ results });
}
render() {
return (
<View>
<View style={{ marginTop: 110 }}>
{
this.state.results.map((result, i) => {
return (
<Text key={i}>
{typeof result === 'object' && !(result instanceof Array) ? 'gold object!' : result.toString()}
</Text>
);
})
}
<TouchableOpacity onPress={() => this.searchBar.show()}>
<View style={{ backgroundColor: 'green', height: 100, marginTop: 50 }}/>
</TouchableOpacity>
<TouchableOpacity onPress={() => this.searchBar.hide()}>
<View style={{ backgroundColor: 'red', height: 100 }}/>
</TouchableOpacity>
</View>
<SearchBar
ref={(ref) => this.searchBar = ref}
data={items}
handleResults={this._handleResults}
showOnLoad
/>
</View>
);
}
}