korkeep

AsyncStore로 두 페이지에서 DB연동 구현

......@@ -7,7 +7,7 @@ import {
SafeAreaView,
ScrollView,
Alert,
TouchableOpacity
TouchableOpacity,
} from "react-native";
import { Icon } from "native-base";
import { AsyncStorage } from "react-native";
......@@ -207,9 +207,13 @@ export default class MovieRankingTab extends Component {
var date = year + "" + month + day;
this.getMovieList(date);
}
_onPressButton(temp) {
Alert.alert(temp);
Alert.alert(temp);//메시지 띄우고
console.log(temp);//콘솔에 log 띄운다
AsyncStorage.setItem('MovieLists', temp); //DB에 저장한다
}
render() {
return (
<SafeAreaView style={style.container}>
......
......@@ -80,14 +80,14 @@ export default class App extends Component {
}
//저장 함수
saveData() {
AsyncStorage.setItem('test', this.state.name0);
}
// saveData() {
// AsyncStorage.setItem('test', this.state.name0);
// }
//출력 함수
displayData = async () => {
try {
let user = await AsyncStorage.getItem('test');
let user = await AsyncStorage.getItem('MovieLists');
alert(user);
}
catch (error) {
......@@ -100,14 +100,15 @@ export default class App extends Component {
return (
<View style={styles.container}>
<View style={styles.top}>
<TouchableOpacity onPress={this.saveData.bind(this)}>
{/* bind해주면 위에 saveData 돌아간다 */}
{/* <TouchableOpacity onPress={this.saveData.bind(this)}>
<Image
style={styles.poster}
source={{ uri: `${this.state.imgurl0}` }}
/>
<Text>{this.state.name0}</Text>
<Text style={styles.textStyle}>영화 정보 저장</Text>
</TouchableOpacity>
</TouchableOpacity> */}
</View>
<View style={styles.bottom}>
......