import React, { useState } from "react"; import { View, Text, TouchableOpacity, Button }…
- User
import React, { useState } from "react"; import { View, Text, TouchableOpacity, Button } from "react-native"; import { FontAwesome6, Ionicons } from "@expo/vector-icons"; import { AntDesign } from "@expo/vector-icons"; import { supabase } from "../supabase"; import {ActivityIndicator, Card, IconButton, Paragraph} from "react-native-paper";
type FeedsProps = { id: string; title: string; content: string; };
export default function Feeds(id:any) { const [isLiked, setIsLiked] = useState(false); const [loading, setLoading] = React.useState(true); const [feeds, setFeeds] = React.useState([]);
codetry { async function getFeeds() { const {data: any, error} = await supabase .from("feeds") .select("*"); if (error) { console.log("error", error); } setFeeds(data); setLoading(false); } } catch (error) { console.log("error", error); } return ( <View style={{ padding: 20 }} >{loading ? ( ) : ( feeds.map((feed, index) => ( <Card.Title title={feed.title} subtitle={feed.content} /> <Card.Content> {feed.content} </Card.Content> <Card.Cover source={{ uri: "https://picsum.photos/700" }} /> <Card.Actions> <IconButton icon="heart" color={isLiked ? "red" : "black"} size={20} onPress={() => setIsLiked(!isLiked)} /> <IconButton icon="share" color="black" size={20} onPress={() => console.log("Shared")} /> </Card.Actions> );
const styles = { button: { borderRadius: 25, width: 50, height: 50, backgroundColor: "blue", justifyContent: "center", alignItems: "center", }, buttonText: { color: "white", fontSize: 20, }, };
fix my code add getFeeds
- Assistant
- User
import React, { useEffect, useState } from "react"; import { View, ActivityIndicator } from "react-native"; import { Card, IconButton, Paragraph } from "react-native-paper"; import { supabase } from "../supabase";
const Feeds = () => { const [isLiked, setIsLiked] = useState(false); const [loading, setLoading] = useState(true); const [feeds, setFeeds] = useState([]);
code - Assistant
- User
import React, { useEffect, useState } from "react"; import { ActivityIndicator, View } from "react-native"; import {Card, IconButton, Paragraph} from "react-native-paper"; import { supabase } from "../supabase";
const Feeds = () => { const [loading, setLoading] = useState(true); const [feeds, setFeeds] = useState([]);
code - Assistant