`i am trying to filter data in a firebase/firestore database table. in fact i have stored user data in a table called users_Infos, the data stored are: name, email and role. i want to filter the role of each user in order to display an appropriate dashboard for them. here documents represent my user list (users_infos) Note that I also have a user that represents the current user and is also an array with a name, email address and uid.
here is the code I'm trying to write that doesn't work.
import { useAuthContext } from '../../hooks/useAuthContext'
import { useCollection } from '../../hooks/useCollection'
import React from 'react'
//styles
import styles from './Home.module.css'
// components
import SkillsFormX from './SkillsFormX
import SkillsFormY from './SkillsFormY
import Footer from '../../components/Footer'
export default function Home() {
const { user } = useAuthContext()
const { documents, error } = useCollection('users_Infos')
return (
<div className="">
<div className="">
{documents.filter(users => users.displayName === user.displayName).map(filteredPerson => (
`</div>`
`<Footer />`
`</div>`
)
}
CodePudding user response:
this don't work
{documents.filter(users => users.displayName === user.displayName).map(filteredPerson => (
CodePudding user response:
I am sharing with you 2 reference URLs I think will be helpful for you -