title: reactjs Onclick event ,sending value to parent
body: <p>I'm fairly very new to ReactJS, JavaScript and whole coding thing.</p>
  
  <p>I have made a list of array that is being passed on to child from parent component, now I want to make a onClick event that whenever user click on any of that list item. </p>
  
  <p>The value (used as key id) is sent back to the parent, so the parent can send that key value to another child which will use conditional rendering based on that key to which component to render. I preferably don't want to use any other library like flux.</p>
  
  <p>I am stuck as I can;t pass that value from child back to parent. There is some confusion about syntax I think or maybe my logic is not correct. I have only able to bind it to a function within the child class to check if the click is being registered.</p>
  
  <pre><code>class Parent extends React.Component {   
   render() {
  var rows = [];
  this.props.listlinkarray.forEach(function(linklist) {
   rows.push(&lt;Child linklist={linklist} key={linklist.key} /&gt;);
   });
  return (
   &lt;div&gt; 
   &lt;h3&gt; ListHead &lt;/h3&gt;
   {rows}
  
   &lt;/div&gt;
  
  );
  }}
  
  class Child extends React.Component {
  // was checking how the Onclick event works //
  getComponent(data,event) {    
    console.log('li item clicked!');
    console.log(data);
    event.currentTarget.style.backgroundColor = '#ccc';
  }  
  render() {
  return (
  &lt;div&gt;
     &lt;ul&gt;&lt;li onClick={this.getComponent.bind(this,this.props.linklist.key)}&gt;
  
  &lt;/div&gt;
     );
    }
   }
  </code></pre>
  
  <p>Array has this data</p>
  
  <pre><code>var ListNameAndLinks= [
  { name:'ABC', key:1} ,
  { name:'BCD', key:2} 
   ];
  </code></pre>
  
  <p>I want to pass the value the parent get from child based on click to this class so it can render based on that value it get.</p>
  
  <pre><code>class Check extends React.Component {
   render() {
     var i = 1 
  // i want that value from parent to this component in if condition
     if (i=1) { 
    return &lt;UIone /&gt;;
  }
   return &lt;UItwo /&gt;;
   }
  }
  </code></pre>