0

The data i queried on firestore

I'm trying to get a data from Figure1 mainly the age. And i tried to loop my map but ended up getting an error.

Unhandled Rejection (TypeError): Cannot read properties of undefined (reading 'map') The error message

export default function TargetClientList() {
const [targetClient, setTargetClient] = useState([]);

useEffect(() => {
    const usersCollectionRef = collection(db, "client");
    const getClientList = async () => {
        const data = await getDocs(usersCollectionRef);
        setTargetClient(data.docs.map((doc) => ({ ...doc.data(), id: doc.id })));
    };
    getClientList();
}, []);

return (
    <Layout>
      <Center py={6}>
            <Table variant="striped" >
                <Tbody>
                    {targetClient.map((works) => {
                        return (
                            <Tr key={works.id}>
                                <Td>{works.first} {works.middle} {works.last}</Td>
                                <Td>
                                    <Stack direction="row" spacing={1}>
                                        <TempModal  works= {works}/>
                                    </Stack>
                                </Td>
                                <Td>
                                    {works.Figure1.map((home) => {
                                        <h1>{home.age}</h1></h1>
                                    })}
                                </Td>
                                <Td>
                                    <Stack direction="row" spacing={1}>
                                        <WorkModal  works= {works}/>
                                    </Stack>
                                </Td>
                            </Tr>
                        );
                    })}
                </Tbody>
            </Table>
        </Center>
    </Layout>
)

}

0 Answers0