title: How to pass data from one variable in props to another in React app?
body: <pre><code>class StarRating extends Component {
    constructor (props) {
      super(props)
  }
  
   log = (selected) =&gt; {
    console.log(selected)
  }
  
    render() {
          return &lt;div&gt;
            &lt;Star
            selected = {true}
            doClick={() =&gt; this.log(this.selected)}
            /&gt;
            &lt;Star /&gt;
            &lt;Star/&gt;
            &lt;Star/&gt;
            &lt;Star/&gt;
            &lt;/div&gt;
          }
  }
  </code></pre>
  
  <p>I need to pass "selected", that is "true" in my case to log, but it's written "undefined", what should I change?</p>
  
  <p>This is Star component. </p>
  
  <pre><code>const Star =  ({selected, doClick=f=&gt;f}) =&gt;
  &lt;div className = {(selected) ? "star selected" : "star"} onClick={doClick}&gt;&lt;/div&gt;
  
  Star.propTypes = {
  selected: PropTypes.bool,
  doClick: PropTypes.func
  }
  export default Star
  </code></pre>