|
@@ -1,5 +1,6 @@
|
|
import React, { Component } from "react";
|
|
import React, { Component } from "react";
|
|
import {
|
|
import {
|
|
|
|
+ AsyncStorage,
|
|
Keyboard,
|
|
Keyboard,
|
|
ListView,
|
|
ListView,
|
|
Platform,
|
|
Platform,
|
|
@@ -64,6 +65,18 @@ class App extends Component {
|
|
this.setSource = this.setSource.bind(this);
|
|
this.setSource = this.setSource.bind(this);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ componentWillMount() {
|
|
|
|
+ AsyncStorage.getItem("items").then((json) => {
|
|
|
|
+ try {
|
|
|
|
+ const items = JSON.parse(json);
|
|
|
|
+ this.setSource(items, items);
|
|
|
|
+ }
|
|
|
|
+ catch (e) {
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+
|
|
handleAddItem() {
|
|
handleAddItem() {
|
|
if (!this.state.value) {
|
|
if (!this.state.value) {
|
|
return;
|
|
return;
|
|
@@ -165,6 +178,7 @@ class App extends Component {
|
|
dataSource: this.state.dataSource.cloneWithRows(itemsDataSource),
|
|
dataSource: this.state.dataSource.cloneWithRows(itemsDataSource),
|
|
...otherState
|
|
...otherState
|
|
});
|
|
});
|
|
|
|
+ AsyncStorage.setItem("items", JSON.stringify(items));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|