How to do it...

  1. We'll start by opening App.js and adding our imports:
import React from 'react';import {  Location,  Permissions,  MapView,  Marker} from 'expo';import {  StyleSheet,  Text,  View,} from 'react-native';
  1. Next, let's define the App class and the initial state. In this recipe, state will only need to keep track of the user's location, which we initialize to null:
export default class App extends Component {  state = {    location: null  }  // Defined in following steps}
  1. Next, we'll define the componentDidMount life cycle hook, which will ask the user to grant permission to access the user's location via the device's geolocation. If the user grants the app permission to use its location, the return object will have a status property with ...

Get React Native Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.