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

165
Visualizações
how do i update my app sidebar dynamicaly
  function TinderCards() {
    const [people, setPeople] = useState([
      {
      name: "Model Baby",
      url:"https://www.themodelskit.co.uk/wp- 
        content/uploads/2021/10/shutterstock_1431963185.jpg",
         age:22
  },
  {
   name: "Seema Jaswal",
     url:"https://static.standard.co.uk/2021/06/14/16/euro_2020_live_seema_jaswal_01-1.jpg? 
 width=968&auto=webp&quality=50&crop=968%3A645%2Csmart", 
    age:32
},
{
 name: 'Baby',
 url: '../assets/IMG_20210811_105110_849.webp'
 age: 34
}
]);

I am pullin data from a datebase that is like the data i created above for illustration purposes

 useEffect(() => {
 const allPeople = query(collection(db, "people"))

   onSnapshot(allPeople, (snapshot) => (
     setPeople(snapshot.docs.map((doc) => doc.data()))
   ))

   return () => {
   second
  }
 }, [])

I am updating the app with the information from the database

  return (
    <div>
    <div className='tinderCards__cardContainer'>
    {people.map((person) => (
        <TinderCard className="swipe" key={person.name} preventSwipe={["up, down"]} onClick= 
 {() => {setPer(person.name)}} >
            <div className='card' style={{ backgroundImage: `url(${person.url})`}}>
                <h3>{person.name}</h3>
            </div>
        </TinderCard>
    ))}
    </div>
</div>
 )
}

export default TinderCards

but how do i update my sidebar with this infomatiom and have the name and other infomation change, eachtime the name changes in the main app

   function RightSidebar() {
    return (
      <div className='rightSidebar'>
    <div className='rightSidebar__contents'>
        <h1>About</h1>
        <Card className='rightSidebar__card'>
            <div className='card__nameContents'>
                    <CardHeader className='card__nameAge' title = {name} subheader = {age} 
 avatar = {<VerifiedIcon className='activeIcon verified' />}  />
                    
                <CardHeader className='card__active' title = "active" avatar= 
 {<FiberManualRecordIcon className='activeIcon' />} />
                
            </div>

The app is quite small do i really need redux or is there a way to track the changes with useState hook?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

How far is the common parent of RightSidebar and TinderCards? If one level up or not too far, store the people data as state of the common parent, pass the data to right sidebar and a function to update the sidebar to TinderCards.

If common parent is far, you can use the React Context API (or the useContext hook). You don't need redux for this

about 4 years ago · Juan Pablo Isaza Relatório
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