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

188
Views
Reaccionar: el producto agregado cambia sus atributos después de agregar otro producto con un atributo diferente mientras está en la misma página del producto

Entonces, digamos que está en la página del producto de una camiseta Nike, elige el color y el tamaño (por ejemplo: negro y S) y lo agrega al carrito. Ahora el carrito contiene 1 CAMISETA Nike con los atributos seleccionados: color: negro, talla: s. Ahora, en la misma página de la camiseta, elige el color blanco y la talla M, los atributos de la camiseta añadida anteriormente cambian de (color:negro a color: blanco, y forma talla:s a talla:M) y ahora tener en carrito 2 CAMISETAS TALLA :M Y COLOR: NEGRO. ¿Qué estoy haciendo mal?

 class PDP extends Component { state = { currentProduct: this.props.location.state, selectState: [], testObj: {}, } render() { let product = this.state.currentProduct; let handleChange = (evt,attribute) => { const test = Object.assign({}, product); this.state.testObj[attribute] = evt.target.value; this.state.selectState.push(this.state.testObj); let selectedAttributes = [...new Set(this.state.selectState)]; test.selectedAttributes = selectedAttributes; this.setState((state) => ({ currentProduct: test })) } <button className="addToCart" onClick={() => this.props.data.addProduct(this.state.currentProduct)}>ADD TO CART</button> addProduct = (product) => { this.setState((state) => ({ cart: state.cart.concat(product), })) }
about 4 years ago · Juan Pablo Isaza
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!