korkeep

일단은 refresh 버튼 누르면 업데이트되는 것까진 구현함

......@@ -12,12 +12,18 @@ import {
import { Icon } from "native-base";
import { AsyncStorage } from "react-native";
import axios from "axios";
import WantToWatchTab from './WantToWatchTab';
const API_KEY = "2bf00f660b1a6a3ffeb6e06ac270cce3";
const NAVER_CLIENT_ID = "KqPsntd1hcPJ8FUPBGqN";
const NAVER_CLIENT_SECRET = "0GRb3uya1U";
//List 전역변수 선언하기
//list = "";
export default class MovieRankingTab extends Component {
state = {
list: "", //Add하고 싶은 정보 list
flag: false, //WantToWatchTab을 새로고침 할지 말지 여부
isLoading: true,
info: [],
date: "",
......@@ -212,9 +218,10 @@ export default class MovieRankingTab extends Component {
_onPressButton(temp) {
//this.state.list = ""; //초기화(On Off 기능으로 짜놨습니당, 누적되는거 보고싶으면 이부분 주석달면 돼여)
Alert.alert(temp);//메시지 띄우고
this.state.list = this.state.list + '\n' + temp; //list 누적해준다(endl으로 구분)
this.state.list = this.state.list + temp + '\n'; //list 누적해준다(endl으로 구분)
console.log(this.state.list);//콘솔에 log 띄운다
AsyncStorage.setItem('MovieLists', this.state.list); //DB에 저장한다
//WantToWatchTab.render(); //새로고침
}
render() {
......
......@@ -10,6 +10,7 @@ import {
} from 'react-native';
import { Icon } from "native-base";
import axios from "axios";
import MovieRankingTab from './MovieRankingTab';
const API_KEY = "2bf00f660b1a6a3ffeb6e06ac270cce3";
const NAVER_CLIENT_ID = "KqPsntd1hcPJ8FUPBGqN";
const NAVER_CLIENT_SECRET = "0GRb3uya1U";
......@@ -83,8 +84,9 @@ export default class App extends Component {
//Data 설정함수
setData = async () => {
try {
this.state.list = await AsyncStorage.getItem('MovieLists'); //List에 받아온다
//console.log(this.state.list); //잘 뜨는데??
//요거 바꿔봤다
this.state.list = await AsyncStorage.getItem('MovieLists'); //List에 받아온다
console.log(this.state.list); //잘 뜨는데??
}
catch (error) {
alert(error)
......@@ -96,8 +98,9 @@ export default class App extends Component {
return (
<View style={styles.container}>
<TouchableOpacity onPress={this.componentDidMount.bind(this)}>
{/* 눌러용 누르면 리스트 갱신됩니다 */}
<Text style={styles.textStyle}>눌러용</Text>
{/* 버튼 누르면 리스트 갱신됩니다 */}
<Image source = {require('../../assets/refresh.png')} />
{/* <Text style={styles.textStyle}>Refresh Button</Text> */}
</TouchableOpacity>
<Text style={styles.textStyle}>{this.state.list}</Text>
</View>
......