Reactjs onClick: How to define the state of the buttons in a list


I have a list of buttons and I'm trying to figure out how to get state of each button that was selected like so (so at any one time I know which button(s) has/have been clicked):

// this.state.selectedTransport:
{ car: true,  train: false, plane: true } or
{ car: false, train: false, plane: true } or
{ car: true,  train: true,  plane: true } etc

see code here:,js,console,output

The main idea is to have the handleClick function in a parent component, and then you call it in your child component to update your parent's state and then pass it as props to your different children. I followed your existing structure and it resulted in something like this: JSbin.