import React, { useContext, useEffect, useState } from "react"; import { View, Text, Image, StyleSheet } from "react-native"; import { getRequest } from "../request"; import { globalStyles } from "../styles/global"; import { windowWidth } from "../utils/Dimensions"; const PostDetailsScreen = ({ navigation, route }) => { const [post, setPost] = useState({}); const fetchPost = async () => { const { data } = await getRequest(`api/posts/${route.params.id}?populate=*`); if (data) { setPost(data.data); } }; useEffect(() => { fetchPost(); }, []); return ( {post?.attributes?.title} {post?.attributes?.description} ); }; const styles = StyleSheet.create({ image: { width: windowWidth, height: 300, }, title: { marginTop: 20, textAlign: "center", }, description: { marginHorizontal: 20 } }); export default PostDetailsScreen;