Jeremy Lindsay
Jeremy Lindsay

Reputation: 139

Where is 'react' located?

I'm using React Native version 0.63. In App.js it says

import React from 'react';
import {
  SafeAreaView,
  StyleSheet,
  ScrollView,
  View,
  Text,
  StatusBar,
} from 'react-native';

Where exactly is react and react-native and how does App.js know where to look? In the main project folder, there is a folder called node_modules which includes two folders called react and react-native, but as far as I can tell they don't export anything called React or View or Text etc.

Upvotes: 1

Views: 123

Answers (1)

lawrence-witt
lawrence-witt

Reputation: 9354

In the first case, React is just the name given to the default export. Usually you could rename it as anything, although React requires that that namespace be included in order for it to function properly.

Go to the index.js file for each node_modules folder and you should see the root export for the package. In my latest React install, the index.js file exports from react.development.js in development, where you can find named exports for all the hooks e.t.c.

In production it exports from the minified bundle react.production.min.js.

Upvotes: 2

Related Questions