-
Notifications
You must be signed in to change notification settings - Fork 3
/
MemHungryArray.js
39 lines (33 loc) · 967 Bytes
/
MemHungryArray.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
import React, { Component } from 'react';
import { Text, View, Button, ScrollView } from 'react-native';
var i = 0;
class MemoryHungryArray extends Component {
static navigationOptions = {
title: 'Screen 2',
};
constructor(props) {
super(props);
this.records = [];
this.state = {
record: ['asdasd'],
};
}
addRecord() {
var { record } = this.state;
i++;
record.push(new Array(999999).join('--' + i));
this.setState({ record });
}
render() {
const { record } = this.state;
const last = record[record.length - 1];
return (
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
<Text>Record length : {JSON.stringify(this.state.record.length)}</Text>
<Button title="Add Record" onPress={() => this.addRecord()} />
<Button title="Remove" onPress={() => this.setState({ record: [] })} />
</View>
);
}
}
export default MemoryHungryArray;