I got this error message when trying to embed react-native-maps functions.
react-native-maps - TypeError: undefined is not an object (evaluating '_this.state.region')
My code
Home.js
import MapView from 'react-native-maps';
export default () => (
<MapView
style={{
position: 'absolute',
top: 0,
left: 0,
right: 0,
bottom: 0,
}}
region={this.state.region}
onRegionChange={this.onRegionChange}
/>
);
index.js
export default class App extends React.Component {
/**/
getInitialState() {
return {
region: {
latitude: 37.78825,
longitude: -122.4324,
latitudeDelta: 0.0922,
longitudeDelta: 0.0421,
},
};
}
onRegionChange(region) {
this.setState({ region });
}
render() {
/**/
}
}