-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
59 lines (48 loc) · 1.28 KB
/
index.js
File metadata and controls
59 lines (48 loc) · 1.28 KB
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
import React, { PureComponent } from "react";
import { ViewPropTypes, NativeModules, Platform } from "react-native";
import PropTypes from "prop-types";
import { TurboModuleRegistry } from 'react-native';
const RNFileSelector = TurboModuleRegistry ? TurboModuleRegistry.get('RNFileSelector') : NativeModules.RNFileSelector;
class FileSelector extends PureComponent {
static propTypes = {
...ViewPropTypes,
filter: PropTypes.string,
path: PropTypes.string,
onDone: PropTypes.func,
onCancel: PropTypes.func,
};
static defaultProps = {
filter: '',
path: '',
};
static Show(props) {
if (props.filter === undefined) {
props.filter = FileSelector.defaultProps.filter
} if (props.path === undefined) {
props.path = FileSelector.defaultProps.path;
}
RNFileSelector.Show(props, path => {
props.onDone && props.onDone(path)
}, () => {
props.onCancel && props.onCancel()
});
}
componentDidMount() {
this._show();
}
componentDidUpdate() {
this._show();
}
_show() {
FileSelector.Show({
filter: this.props.filter,
path: this.props.path,
onDone: this.props.onDone,
onCancel: this.props.onCancel
});
}
render() {
return null;
}
}
export default FileSelector;