커뮤니티
포인트
쿠폰
내 강의실
국비 신청 내역
증명서
계정
로그아웃
학습 질문
개발 일지
나의 활동
답변 완료
firebase다시 공부중인데...detailPage에
[왕초보] 나만의 수익성 앱, 앱개발 종합반 v3
4주차
북마크
박*수
댓글
2
추천
0
조회수
9
조회수
9
답변 완료

* 겪고 있는 문제 상황을 최대한 자세하게 작성해주세요.

* 문제 해결을 위해 어떤 시도를 해보았는지 구체적으로 함께 알려주세요.




 import React, { useState, useEffect } from 'react';

import { StyleSheet, Text, View, Image, ScrollView, TouchableOpacity, Alert, Share, Platform } from 'react-native';

import * as Linking from 'expo-linking'; import { firebase_db } from "../firebaseConfig"

import * as Application from 'expo-application'; 

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

export default function DetailPage({ navigation, route }) {

    const [tip, setTip] = useState({

        "idx": 9,

        "category": "재테크",

        "title": "렌탈 서비스 금액 비교해보기",

        "image": "https://storage.googleapis.com/sparta-image.appspot.com/lecture/money1.png",

        "desc": "요즘은 정수기, 공기 청정기, 자동차나 장난감 등 다양한 대여서비스가 활발합니다. 사는 것보다 경제적이라고 생각해 렌탈 서비스를 이용하는 분들이 늘어나고 있는데요. 다만, 이런 렌탈 서비스 이용이 하나둘 늘어나다 보면 그 금액은 겉잡을 수 없이 불어나게 됩니다. 특히, 렌탈 서비스는 빌려주는 물건의 관리비용까지 포함된 것이기에 생각만큼 저렴하지 않습니다. 직접 관리하며 사용할 수 있는 물건이 있는지 살펴보고, 렌탈 서비스 항목에서 제외해보세요. 렌탈 비용과 구매 비용, 관리 비용을 여러모로 비교해보고 고민해보는 것이 좋습니다. ",

        "date": "2020.09.09"

    })

    useEffect(() => {

        console.log(route)

        navigation.setOptions({

            title: route.params.title,

            headerStyle: {

                backgroundColor: '#000',

                shadowColor: "#000",

            },

            headerTintColor: "#fff",

        })

        //넘어온 데이터는 route.params에 들어 있습니다.         

        const { idx } = route.params;

        firebase_db.ref('/tip/' + idx).once('value').then((snapshot) => {

            let tip = snapshot.val();

            setTip(tip)        

        })

    }, [])

    const like = async () => {

        // like 방 안에        

        // 특정 사용자 방안에        

        // 특정 찜 데이터 아이디 방안에        

        // 특정 찜 데이터 몽땅 저장!        

        // 찜 데이터 방 > 사용자 방 > 어떤 찜인지 아이디         

        let userUniqueId;

        if (isIOS) {

            let iosId = await Application.getIosIdForVendorAsync();

            userUniqueId = iosId

        } else {

            userUniqueId = await Application.androidId

        } console.log(userUniqueId)

        firebase_db.ref('/like/' + user_id + '/' + tip.idx).set(tip, function (error) {

            console.log(error)

            Alert.alert("찜 완료!")

        });

    }

    const share = () => {

        Share.share({

            message: `${tip.title} \n\n ${tip.desc} \n\n ${tip.image}`,

        });

    }







이해가 잘 안되는 부분이 있어 막히네요...저기 useEffect 함수에서

const { index} = route.params

이 부분이 route.params는 어디서 정보를 받아오는 걸 의미하나요??

계속 Cannot read property 'params' of undefined라고 뜨네요

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