Listing 6-19: Setting defaultProps outside of the component body
37.3230
122.0322
37.3230
122.0322
import {Component} from 'react';
import Map from './Map';
import StoreList from './StoreList';
class StoresNearYou4 extends Component{
render(){
return(
<>
<div id="map-container">
<Map
latitude={this.props.latitude}
longitude={this.props.longitude}
/>
</div>
<div id="store-list">
<StoreList
latitude={this.props.latitude}
longitude={this.props.longitude}
/>
</div>
</>
)
}
}
StoresNearYou4.defaultProps = {
latitude: "37.3230",
longitude: "122.0322"
}
export default StoresNearYou4;
Download the examples, report issues, and ask/answer questions in the discussion area by visiting the book's github page. All of the code for the book is also available on codesandbox.io for you to play around with.
ReactJS Foundations is published by John Wiley and Sons, Inc and is available in paperback and eBook.