Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

240
Visualizações
I'm making blog page in react using react router and firebase firestore , and i want get single post detail by id

Hello everyone I'm making sort of blog page and have problem with retrieving data for single item from database I searched solution for this problem and I just can't find it. In this project I use firestore and react router. This is my Home function (Home page), where i retrive items from database

function Home({isAuth}) {
  const[articlesList, setArticleList] = useState([])
  const articleCollectionRef = collection(db, 'articles')

  const deleteArticle = async (id) => {
      const articleDoc = doc(db, "articles", id)
      await deleteDoc(articleDoc)
  }
  
  useEffect(() => {
      const getArticles = async () => {
      const data = await getDocs(articleCollectionRef)
      setArticleList(data.docs.map((doc) => ({...doc.data(), id: doc.id})))
    }
      getArticles()
    },[deleteArticle])

  
 
  return <Grid container direction="row-reverse" justifyContent="space-evenly" alignItems="center" marginTop={2} >
    {articlesList.map((article) => {
      return(
          <Grid item alignItems="center" margin={1}>
            <Link to={`articles/${article.id}`} articlesList={articlesList} ><PostCard isAuth={isAuth} article={article} deleteArticle={deleteArticle}/></Link>
          </Grid>
    )})}
  </Grid>
}

export default Home;

And here is my single article component where i get item id with useParams but i dont know how to get item based on that id


const SingleArticle = () => {
  
  const { id } = useParams()

  return (
    <>
      < h5>Post with id: { id }</h5>
    </>
  )
}
about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda