Estoy tratando de agregar los atributos seleccionados (botones de opción) al producto. con los atributos seleccionados, obtengo una matriz de un solo objeto con varias claves/valores.
render() { let product = this.state.currentProduct; let selectedAttributes = []; let testobj = {}; let handleChange = (evt,attribute) => { let test = Object.assign({}, product); testobj[attribute] = evt.target.value; selectedAttributes.push(testobj); let noDuplicates = [...new Set(selectedAttributes)]; test.selectedAttributes = noDuplicates; this.setState((state) => ({ currentProduct: test, })) } return ( <> <ul className={`attributesList ${attribute.id}`} key={attribute.id}> {product.attributes[i].items.map((item) => { return ( <li> <input className={attribute.id} onChange={(evt) => handleChange(evt,attribute.id)} type="radio" id={`attribute ${attribute.id} ${item.id}`} name={`attributesList ${attribute.id}`} value={item.displayValue}/> <label className={`attribute ${item.id}`} style={{backgroundColor: item.value}} htmlFor={`attribute ${attribute.id} ${item.id}`}>{item.displayValue}</label> </li> ) })} </ul>