score:0

for access to the value of the button, you can pass the value into the onClick method

import * as React from 'react'
import * as ReactDOM from 'react-dom'
import './ui.css'

declare function require(path: string): any

class App extends React.Component {
state={currentValue:''}
  cornerRadiusValues = [4, 8, 16, 24, 32, 40, 48];
  
  cornerRadiusButtons = this.cornerRadiusValues.map((cornerRadiusValue, index) =>
  <button key={index} value={cornerRadiusValue} id="cornerRadiusValue" 
onClick={() => this.setAttibute(cornerRadiusValue)}>{cornerRadiusValue}</button>
  );

  setAttibute = (value) => {
    this.setState({
...this.state,
currentValue:value
})
  }

  render() {
    return <div>
      {this.cornerRadiusButtons}
    </div>
  }
}

ReactDOM.render(<App />, document.getElementById('react-page'))

and you can access the value of state inside of component with this command this.state.currentValue

Copy an object to another one

var firstObject = {
    key1 : 'value1',
    key2 : 'value2'
};

var secondObject = {
    ...firstObject,
    key3 : 'value3',
    key4 : 'value4'
};


Related Query

More Query from same tag