Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

241
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda