Tried this, but it doesn't seems to work for me.
let ratingValue = [{ val: 1 }, { val: 2 }, { val: 3 }, { val: 4 }, { val: 5 }, { val: 6 }];
class Scale extends Component {
constructor(props) {
super(props);
this.handleButtonClicked = this.handleButtonClicked.bind(this);
}
handleButtonClicked(buttonNumber, buttonValue) {
console.log("User Pressed " + buttonNumber + "with Rating of " + buttonValue);
}
render() {
let buttonsMap = ratingValue.map((button, index) => {
return (
<button key={index} onClick={this.handleButtonClicked(index, button.val)}>
{button.val}
</button>
);
});
return <div>{buttonsMap}</div>;