Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

174
Views
Quiero cambiar el contador de elementos individuales, pero cuando incremento el recuento, aumenta el recuento de todos los elementos.

Lo que quiero es incrementar el recuento de cada elemento individual, pero cuando intento hacerlo, cambia para cada elemento representado. Estoy obteniendo datos de la API y buscándolos en la tienda redux y mapeando la matriz. Pero no podía diferenciar cada elemento.

 return ( <View style={styles.Container}> {movies ? ( movies.map((data,i) => { const IMAGE_URL = data.image; return ( <Card key={i}> <View style={styles.Content}> <Card.Cover style={styles.image} source={{ uri: IMAGE_URL }} /> <ScrollView style={styles.ProductDetails}> <Text style={{ fontSize: 15, fontWeight: "bold", paddingBottom: 10, }} > {data.title} </Text> <Paragraph>{data.description}</Paragraph> </ScrollView> </View> <View style={styles.BottomButtonView}> <View style={{ flexDirection: "row", alignItems: "center" }}> <TouchableOpacity key={i} style={styles.ButtonContainer} onPress={() => setCount(count+1)} > <Text style={{ color: "white" }}>+</Text> </TouchableOpacity> <Text style={{ padding: 10 }}>{count}</Text> <TouchableOpacity style={styles.ButtonContainer} onPress={() => console.log('dec')} > <Text style={{ color: "white" }}>-</Text> </TouchableOpacity> </View> <TouchableOpacity onPress={() => console.log("Added to Cart")} style={styles.AddToCart} > <Text style={{ color: "white" }}>${data.price}</Text> </TouchableOpacity> </View> </Card> ); }) ) : ( <Text>Getting Data....</Text> )} </View> ); }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Actualización de un elemento en una matriz:

 function updateObjectInArray(array, action) { return array.map((item, index) => { if (index !== action.index) { // This isn't the item we care about - keep it as-is return item } // Otherwise, this is the one we want - return an updated value return { ...item, ...action.item } }) }

por ejemplo :

 const changePrice = (itemArray, item) => { return itemArray.map(reduxItem => { if(reduxItem.id === item.id){ reduxItem.price = reduxItem.price + reduxItem.price } return reduxItem }); };
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!