Import and Export Modules

React Native 5 min min read Updated: Jul 25, 2026 Beginner
Import and Export Modules
Beginner Topic 4 of 5

Import and Export Modules

Every React Native project is organized into multiple files, and the ES6 module system using import and export statements is what allows these files to share code with one another. This tutorial explains how modules work in React Native.

Why Modules Matter

Splitting code into separate files improves organization, reusability, and maintainability. Instead of writing everything in a single file, developers create components, utilities, and constants in separate modules and import them where needed.

Default Exports

A default export allows a file to export a single primary value, which is commonly used for exporting React Native components.

javascript // Button.js import React from 'react'; import { TouchableOpacity, Text } from 'react-native'; function Button({ label }) { return ( {label} ); } export default Button;

Importing a Default Export

javascript import Button from './Button';

Named Exports

Named exports allow a single file to export multiple values, which must be imported using the exact same names, optionally wrapped in curly braces.

javascript // constants.js export const API_URL = 'https://api.example.com'; export const APP_NAME = 'MyApp';

Importing Named Exports

javascript import { API_URL, APP_NAME } from './constants';

Combining Default and Named Exports

A single file can contain both a default export and multiple named exports, which is a common pattern for component files that also export related helper functions or constants.

Renaming Imports

You can rename an imported value using the as keyword, which is useful for avoiding naming conflicts between modules.

javascript import { APP_NAME as ApplicationName } from './constants';

Conclusion

Understanding import and export syntax is fundamental to organizing a React Native project effectively. Proper use of modules keeps your codebase clean, reusable, and easy to navigate as your application grows in size and complexity.

Get Newsletter

Subscibe to our newsletter and we will notify you about the newest updates on Edugators