@beletsky/react-native-yandex-ads
Version:
51 lines • 1.9 kB
JavaScript
// @ts-nocheck
import React, { memo, useRef } from 'react';
import { AdNative as AdNativeComponent } from '../components';
export const AdNative = /*#__PURE__*/memo(_ref => {
let {
adUnitId,
style,
width = 100,
height = 100,
onCloseAd,
onDidLoad,
requestParams = {}
} = _ref;
// if (!adUnitId) {
// throw Error(
// '[YandexAdsNative]\nThe adUnitId parameter is not set. It is mandatory. Perhaps you forgot to specify the adUnitId of the block?'
// )
// }
if (!(style !== null && style !== void 0 && style.width)) {
throw Error('[YandexAdsNative]\nThe ad block width parameter is not set. It is mandatory. Perhaps you forgot to specify the width of the block?');
}
// if (!style?.height) {
// throw Error(
// '[YandexAdsNative]\nThe ad block height parameter is not set. It is mandatory. Perhaps you forgot to specify the height of the block?'
// )
// }
const ref = useRef(null);
return /*#__PURE__*/React.createElement(AdNativeComponent, {
adUnitId: adUnitId ?? 'undefined',
style: {
flexDirection: 'row',
display: 'flex',
width
},
height: height,
width: width,
onDidLoad: d => onDidLoad === null || onDidLoad === void 0 ? void 0 : onDidLoad(d.nativeEvent),
onWillLoad: () => console.log('The ad block has been prepared for loading'),
onDidTrackImpression: () => console.log('onDidTrackImpression'),
onWillPresent: () => console.log('onWillPresent'),
onWillLeaveApp: () => console.log('onWillLeaveApp'),
onDidDismiss: () => console.log('onDidDismiss'),
onClick: () => console.log('onClick'),
onClose: onCloseAd,
onTouchEnd: () => console.log('A click on an ad block has been registered'),
onDidFailLoading: e => console.log('error: ', e.nativeEvent),
requestParams: requestParams,
ref: ref
});
});
//# sourceMappingURL=index.ios.js.map