Knowing the project structure helps you find files easily and understand how your app is organized.
Project structure overview in React Native
myApp/ ├─ android/ ├─ ios/ ├─ src/ │ ├─ components/ │ ├─ screens/ │ ├─ assets/ │ ├─ App.js ├─ package.json ├─ babel.config.js └─ node_modules/
android/ and ios/ folders contain platform-specific code.
src/ is where your app's main code lives, like components and screens.
src folder: a button component, a home screen, and an image.src/components/Button.js src/screens/HomeScreen.js src/assets/logo.png
package.json babel.config.js node_modules/
This is a simple React Native app component placed inside src/App.js. It shows a welcome message centered on the screen.
import React from 'react'; import { View, Text, StyleSheet } from 'react-native'; export default function App() { return ( <View style={styles.container}> <Text style={styles.title}>Welcome to MyApp</Text> </View> ); } const styles = StyleSheet.create({ container: { flex: 1, justifyContent: 'center', alignItems: 'center', backgroundColor: '#f0f0f0' }, title: { fontSize: 24, fontWeight: 'bold' } });
Keep your code organized by grouping similar files in folders like components and screens.
Platform folders android and ios are usually not changed often unless you add native code.
Use package.json to manage your app's dependencies and scripts.
React Native projects have folders for platform code and app code.
Organize your app code inside src for clarity.
Understanding structure helps you build and maintain your app easily.
Practice
Solution
Step 1: Understand folder roles
Theandroidandiosfolders contain platform-specific native code, not app logic.Step 2: Identify app code location
App code is best organized inside asrcfolder to keep it separate and clear.Final Answer:
Inside a folder namedsrc-> Option CQuick Check:
App code =srcfolder [OK]
src folder, not platform folders [OK]- Putting app code inside
androidoriosfolders - Keeping all code in the root folder without organization
Solution
Step 1: Recall standard folder names
React Native usesandroidas the folder name for Android platform code by default.Step 2: Compare options
Onlyandroidmatches the exact folder name used by React Native.Final Answer:
android -> Option AQuick Check:
Android folder =android[OK]
android and ios [OK]- Using camelCase or underscores in platform folder names
- Confusing app code folder with platform folders
myApp/ ├── android/ ├── ios/ ├── src/ │ └── App.js └── package.jsonWhere will the main app component be located?
Solution
Step 1: Analyze folder contents
Thesrcfolder containsApp.js, which is the main app component file.Step 2: Understand platform folders
Theandroidandiosfolders hold native code, not React Native components.Final Answer:
Insidesrcfolder -> Option DQuick Check:
Main app component =src/App.js[OK]
src, not platform folders [OK]- Assuming main app code is inside
androidorios - Looking for app code in the root folder
myApp/ ├── android/ ├── ios/ ├── app/ │ └── App.js └── package.jsonWhat is the likely cause?
Solution
Step 1: Identify folder mismatch
The app code is inappfolder, but React Native expects it insrcor root by default.Step 2: Understand module resolution
Since the code is not where expected, the bundler cannot find./Appmodule.Final Answer:
App code is insideappfolder but should be insrc-> Option BQuick Check:
App folder mismatch = module not found error [OK]
- Ignoring folder naming conventions
- Assuming platform folders hold app code
- Not checking import paths
Solution
Step 1: Understand best practices for organization
Keeping feature code insidesrcin dedicated folders helps maintain clarity and separation.Step 2: Avoid mixing platform and app code
Platform foldersandroidandiosare for native code, not React Native components.Final Answer:
Create a new folder insidesrcfor the feature components -> Option AQuick Check:
Organize features insidesrcfor maintainability [OK]
src in separate folders [OK]- Adding app code to platform folders
- Cluttering root folder with many files
- Not grouping related files
Ready to prove it?
Pass the test and this pattern moves unknown
