커뮤니티
포인트
쿠폰
내 강의실
국비 신청 내역
증명서
계정
로그아웃
학습 질문
개발 일지
나의 활동
답변 완료
숙제5. 찜해제버튼누르면 삭제완료 팝업까지는 떳는데 꿀팁찜목록에서 사라지지않아요;;
[왕초보] 나만의 수익성 앱, 앱개발 종합반
4주차
북마크
이*정
댓글
3
추천
0
조회수
18
조회수
18
답변 완료

라이크카드.js코드


import React from 'react';

import {Alert, View, Image, Text, StyleSheet,TouchableOpacity} from 'react-native'

import {firebase_db} from "../firebaseConfig"

const isIOS = Platform.OS === 'ios';

import * as Application from 'expo-application';

//MainPage로 부터 navigation 속성을 전달받아 Card 컴포넌트 안에서 사용

export default function LikeCard({content,navigation,tip, setTip}){



//MainPage로 부터 navigation 속성을 전달받아 Card 컴포넌트 안에서 사용



  const detail = () => {

    navigation.navigate('DetailPage',{idx:content.idx})

}

const remove = async (삭제찜카드) => {

  let userUniqueId;

  if(isIOS){

  let iosId = await Application.getIosIdForVendorAsync();

      userUniqueId = iosId

  }else{

      userUniqueId = await Application.androidId

  }

 

console.log(userUniqueId)

         firebase_db.ref('/like/'+userUniqueId+'/'+삭제찜카드).remove().then(function(){

             

         Alert.alert("삭제 완료!");

         let result = tip.filter((data,i)=>{

          return data.idx !== 삭제찜카드

        })

          console.log(result)

          setTip(result)

        })

     

     


      return(

     

        <View style={styles.card}>

            <Image style={styles.cardImage} source={{uri:content.image}}/>

            <View style={styles.cardText}>

                <Text style={styles.cardTitle} numberOfLines={1}>{content.title}</Text>

                <Text style={styles.cardDesc} numberOfLines={3}>{content.desc}</Text>

                <Text style={styles.cardDate}>{content.date}</Text>

                <View style={styles.buttonGroup}>

                    <TouchableOpacity style={styles.button} onPress={()=>detail()}><Text style={styles.buttonText}>자세히 보기</Text></TouchableOpacity>

                    <TouchableOpacity style={styles.button} onPress={()=>remove()}><Text style={styles.buttonText}>찜 해제</Text></TouchableOpacity>

                </View>

         

               

            </View>

        </View>

    )  

}



const styles = StyleSheet.create({

   

    card:{

      flex:1,

      flexDirection:"row",

      margin:10,

      borderBottomWidth:0.5,

      borderBottomColor:"#eee",

      paddingBottom:10

    },

    cardImage: {

      flex:1,

      width:100,

      height:100,

      borderRadius:10,

    },

    cardText: {

      flex:2,

      flexDirection:"column",

      marginLeft:10,

    },

    cardTitle: {

      fontSize:20,

      fontWeight:"700"

    },

    cardDesc: {

      fontSize:14

    },

    cardDate: {

      fontSize:10,

      color:"#A6A6A6",

    },

    buttonGroup: {

      flexDirection:"row",

    },

    button:{

       width:90,

       marginTop:20,

       marginRight:10,

       marginLeft:10,

       padding:10,

       borderWidth:1,

       borderColor:'deeppink',

       borderRadius:7

    },

    buttonText:{

       color:'deeppink',

       textAlign:'center',

       fontSize:8

  }

});


취소
 공유
취소
댓글 0
댓글 알림
나의얼굴