-
Notifications
You must be signed in to change notification settings - Fork 0
/
AdsList.js
56 lines (49 loc) · 1.17 KB
/
AdsList.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
48
49
50
51
52
53
54
55
56
import React, {PureComponent, memo} from 'react';
import {FlatList, View} from 'react-native';
import PublisherBanner from './PublisherBanner';
const PureComp = memo(({index}) => {
if (index % 2 === 0) {
return (
<View
style={{
margin: 2,
backgroundColor: 'red',
width: 200,
height: 400,
}}
/>
);
}
return (
<View style={{padding: 16}}>
<PublisherBanner
adSize="banner"
adUnitID="/6499/example/banner"
testDevices={[PublisherBanner.simulatorId]}
onAdFailedToLoad={error => console.error(error)}
onAppEvent={event => console.log(event.name, event.info)}
/>
</View>
);
});
class AdsList extends PureComponent {
constructor(props) {
super(props);
this.contentList = Array(100).fill(0);
}
renderItem = ({index}) => {
return <PureComp index={index} />;
};
keyExtractor = (item, index) => `${index}`;
render() {
return (
<FlatList
data={this.contentList}
renderItem={this.renderItem}
initialNumToRender={5}
keyExtractor={this.keyExtractor}
/>
);
}
}
export default AdsList;