BannerView.js
1.01 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
import React, {Component} from 'react';
import ReactNative from 'react-native';
import PropTypes from 'prop-types';
let { requireNativeComponent } = ReactNative;
// requireNativeComponent automatically resolves this to "YH_BannerViewManager"
module.exports = requireNativeComponent('YH_BannerView', null);
class BannerView extends React.Component {
constructor(props) {
super(props);
this._onSelectBanner = this._onSelectBanner.bind(this);
}
_onSelectBanner(event: Event) {
if (!this.props.onSelectBanner) {
return;
}
this.props.onSelectBanner(event.nativeEvent.url);
}
render() {
return <YH_BannerView {...this.props} onPress={this._onSelectBanner} />;
}
}
BannerView.propTypes = {
autoLooping: PropTypes.bool,
items: PropTypes.arrayOf(
PropTypes.shape({
src: PropTypes.string.isRequired,
url: PropTypes.string.isRequired,
})
),
onSelectBanner: PropTypes.func,
};
let YH_BannerView = requireNativeComponent('YH_BannerView', BannerView);
module.exports = BannerView;