-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathTeadsAdView.js
48 lines (40 loc) · 1.08 KB
/
TeadsAdView.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
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { requireNativeComponent, Dimensions, View } from 'react-native';
export class AdView extends Component {
constructor(props) {
super(props);
this.state = {
width: Dimensions.get('window').width,
height: 2,
adHeight: Dimensions.get('window').width / 1.77
};
}
onTeadsAdLoaded = ({nativeEvent}) => {
this.setState({
height: this.state.width / nativeEvent.adRatio
})
}
render() {
return (
<TeadsNativeAdView
enableDebud={true}
style={{
width: Math.round(this.state.width),
height: 300
}}
pid={84242}
load={true}
onTeadsAdLoaded={this.onTeadsAdLoaded}
/>
)
}
}
AdView.propTypes = {
onTeadsLayout: PropTypes.func
}
const TeadsNativeAdView = requireNativeComponent(
'TFACustomAdView',
AdView,
)
export default AdView