Purpose of "export default App" in React-Native

Im new to React-Native and I cant seem to understand the need for export default App
Have a look at the code below

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

 class App extends React.Component {
 render() {
  return (
     <View style={styles.container}>
       <Text>Hello World! This is my first program</Text>
 const styles = StyleSheet.create({
   container: {
     flex: 1,
     backgroundColor: '#fff',
     alignItems: 'center',
     justifyContent: 'center',

export default App;

So if I comment out the last line and run it using expo I encounter errors…
else it works fine
can someone explain the need for the last line
( I am just running this file,am not linking any other files)

I tried searching on the net and all I encountered was loading modules from the source file to current working file…. I didn’t find any for the same file…

EDIT1:@pnizzle cleared it up.

So "export" is the key to allow access to other components (even if you don’t link this file to other files),it has to be exposed in order for the RN code to run.

2 thoughts on “Purpose of "export default App" in React-Native”

Leave a Comment