BannerView.js 893 Bytes
import React, {Component} from 'react';
import ReactNative from 'react-native';
import PropTypes from 'prop-types';

let { requireNativeComponent } = ReactNative;

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;