Untitled

mail@pastecode.io avatar
unknown
plain_text
3 years ago
718 B
2
Indexable
Never
useEffect(() => {
        if(props.route.params.postId !== postId )
            firebase.firestore()
            .collection('posts')
            .doc(props.route.params.uid)
            .collection('userPosts')
            .doc(props.route.params.postId)
            .collection('comments')
            .get()
            .then((snapshot) => {
                let comments = snapshot.docs.map(doc => {
                    const data = doc.data()
                    const id = doc.id;
                    return {id, ...data}

                })
                this.setState({Setcomments: comments})
            })
            this.setState({postId: props.route.params.postId })

    }, [props.route.params.postId]);