title: Pass data from component to another component
body: <p>I am new to react and I try to pass data from a functional component to a class component. This is the code that I try in the functional component.</p>
  <pre><code>function ViewLocation() {
      const long = posts?.location?.longitude;
      const lat=posts?.location?.latitude;
      const location={lat,long};
  
      return(
         &lt;Map loc={location}/&gt;
      );
  }
  
  export default ViewLocation;
  </code></pre>
  <p>This is the code that I try in the class component.</p>
  <pre><code>const AnyReactComponent = ({ text }) =&gt; &lt;div&gt;{text}&lt;/div&gt;;
  
  class Map extends Component {
      static defaultProps = {
          center: {
              lat: 48.639512204153604,
              lng: 1.6496781699692729
          },
          zoom: 11
      };
      render() {
          const {lat, long}=this.props.loc;
  
          return (
               &lt;div className=&quot;location-box-b&quot; style={{ height: '100vh', width: '100%' }}&gt;
                    &lt;GoogleMapReact
                      bootstrapURLKeys={{ key: &quot;&quot; }}
                      defaultCenter={this.props.center}
                      defaultZoom={this.props.zoom}
                    &gt;
                    &lt;AnyReactComponent
                      lat={lat}
                      lng={long}
                      text=&quot;Seller's Location&quot;
                     /&gt;
                    &lt;/GoogleMapReact&gt;
               &lt;/div&gt;
          );
      }
  }
  export default Map;
  </code></pre>
  <p>When I try to set the default center I have to put data to this code part.</p>
  <pre><code>static defaultProps = {
    center: {
      lat: 48.639512204153604,
      lng: 1.6496781699692729
    },
      zoom: 11
  };
  </code></pre>
  <p>But when I try to change the values like this</p>
  <pre><code>static defaultProps = {
    center: {
      lat: this.props.loc.lat,
      lng: this.props.loc.long
    },
      zoom: 11
  };
  </code></pre>
  <p>I get the error 'TypeError: Cannot read property 'loc' of undefined'. How do I solve this issue?</p>