title: Passing data between a class and a functional component - React JS
body: <p>I am using React and React Router.</p>
  <p>Here is my first component:</p>
  <pre><code>import React from 'react';
  
  class SomeClass extends React.Component{
      constructor(props){
          super(props);
          this.state = {
                someObj: {
                  something: &quot;&quot;,
                  someOtherThing: &quot;&quot;
                },
              authenticated: false
          };
      }
  
  }
  
  
  
  export default SomeClass;
  </code></pre>
  <p>Here is my ProtectedRoute component:
  const ProtectedRoute = ({auth, component: Component, ...rest}) =&gt;{
  return(
  &lt;Route {...rest} render={(props) =&gt;{</p>
  <pre><code>            if(auth){
                  return(&lt;Component {...props} /&gt;);
              }
  
              if(!auth){
                  return(&lt;Redirect to={{path: &quot;/&quot;, state:{from: props.location}}} /&gt;);
              }
          }} /&gt;
      );
  };
  
  export default ProtectedRoute;
  </code></pre>
  <p>Here is my Nav component:</p>
  <pre><code>import React from 'react';
  import { BrowserRouter as Router, Switch} from 'react-router-dom';
  import ProtectedRoute from './ProtectedRoute';
  import SomeClass from './SomeClass';
  
  function Nav(){
      return(
          &lt;Router&gt;
              &lt;Switch&gt;
                  &lt;ProtectedRoute exact path=&quot;/somepage/abc&quot; component={SomeClass} auth={SomeClass.props.authenticated} /&gt;  //getting an error here because of SomeClass.props.authenticated
              &lt;/Switch&gt;
          &lt;/Router&gt;
  
      );
  }
  
  
  export default Nav;
  </code></pre>
  <p>My Question:</p>
  <p>In my Nav functional component, there is the &lt;ProtectedRoute ....&gt;, I want to get the authenticated value from the SomeClass's authenticated value (this.state.authenticated)?</p>
  <p>When I do SomeClass.props.authenticated I get the following error:</p>
  <blockquote>
  <p>TypeError: Cannot read property 'authenticated' of undefined</p>
  </blockquote>