Shareef Dweikat
Shareef Dweikat

Reputation: 809

Why create-react-native-app does not has ios and android files anymore?

I am learning react native. i need to access to android and ios files so i can add maps to my app, but i cant find them!

i tried looking inside assets file, node modules file. but could not find them.

this is an image showing my project files

Upvotes: 1

Views: 488

Answers (1)

Andrew
Andrew

Reputation: 28539

You’ve created your app with Expo.

Expo abstracts away the native code, meaning that you don’t have to deal with it. So this means that no matter how hard you look inside an Expo app you won’t find any native code.

This can be beneficial if you don’t have access to a Mac for iOS development. It also means that you only need to write in Javascript and not worry about writing code in java or objective-c.

However, Expo has access to maps in it. Check out MapView it uses Apple and Google maps to display maps in your app, so you don’t need to add another dependency. https://docs.expo.io/versions/v32.0.0/sdk/map-view/

It’s very straight forward to use. You don’t have to install anything you can just import from Expo here is a sample

import React from 'react';
import { MapView } from 'expo';

export default class App extends React.Component {
  render() {
     return (
      <MapView
          style={{ flex: 1 }}
          initialRegion={{
          latitude: 37.78825,
          longitude: -122.4324,
          latitudeDelta: 0.0922,
          longitudeDelta: 0.0421,
          }}
      />
    );
  }
}

If you want to have access to the native code you either have to create your app using react-native init YourAppName or you can eject your Expo

To eject your app run expo eject in the terminal.

You can read more about it here : https://docs.expo.io/versions/latest/expokit/eject/

There are pros and cons for ejecting. But if you need access to native code then you will have to eject.

Upvotes: 3

Related Questions