When working with React Native CLI, having a well-structured project is key to scalability, maintainability, and efficiency. Below is an ideal folder structure along with comments explaining each folder's purpose to keep your project clean and organized!
π¨ Note: Everyone has their own coding style, and following this structure is not mandatory. Itβs just a guideline to help you organize your project better!
π Recommended Folder Structure
π YourProjectName
β£ π android/ # β οΈ Native Android code (Java/Kotlin) β DO NOT modify unless necessary!
β£ π ios/ # β οΈ Native iOS code (Swift/Objective-C) β DO NOT modify unless necessary!
β£ π src/ # Main source code
β β£ π assets/ # π Stores images, fonts, icons, etc.
β β£ π components/ # π Reusable UI components (Button, Card, etc.)
β β£ π screens/ # π Screens (Home, Login, Profile)
β β£ π navigation/ # π Navigation setup (React Navigation)
β β£ π redux/ # π Redux store, slices (if using Redux)
β β£ π hooks/ # π Custom hooks for reusable logic
β β£ π utils/ # π Utility/helper functions (date formatting, API calls, etc.)
β β£ π constants/ # π Stores app-wide constants (colors, fonts, etc.)
β β£ π services/ # π API services (Axios, Firebase, etc.)
β β£ π App.tsx # π Root component
β β£ π index.tsx # π Entry point of the app
β£ π .gitignore # π Files to ignore in Git
β£ π package.json # π Project dependencies
β£ π tsconfig.json # π TypeScript configuration (if using TS)
β£ π babel.config.js # π Babel configuration
β£ π metro.config.js # π Metro bundler configuration
β£ π react-native.config.js# π React Native CLI configuration
π Important Guidelines
β οΈ DO NOT modify the android/ and ios/ folders unless you are working with native code (e.g., linking third-party libraries, modifying native modules, or changing build settings).
π‘ Pro Tip: Use absolute imports (@components, @screens) in your tsconfig.json to avoid messy ../../../ imports!
π Follow this structure to make your React Native projects more organized and easier to manage! But remember, coding is all about flexibilityβorganize your project in a way that works best for you! Happy coding! π₯π #ReactNative #MobileDevelopment #BestPractices
Letβs keep learning and growing together!π
Top comments (0)