alan2207 / bulletproof-react

🛡️ ⚛️ A simple, scalable, and powerful architecture for building production ready React applications.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Where must I put these files? [React, React Native]

gianllopez opened this issue · comments

First of all, I want to thank you for the fascinating work you are doing, but I have the following situation:

In my React Native project, I have the following folder structure:

src
├── assets
│   ├── fonts
│   │   ├── *.ttf
│   └── icons
│       └── *.svg
├── components
│   ├── *.tsx
├── config
│   ├── constants.ts
│   └── theme
│       └── colors.js
├── features
│   ├── malls
│   │   ├── components
│   │   │   ├── *.tsx
│   │   ├── index.ts
│   │   └── screens
│   │       ├── *.tsx
│   │       └── index.ts
│   └── users
│       ├── interfaces
│       │   ├── *.ts
│       └── screens
│           ├── *.tsx
│           └── index.ts
├── lib
│   └── react-native-vector-icons
│       └── *.json
└── navigation
    ├── navigators
    │   ├── *.tsx
    └── types
        ├── *.ts

And I have several questions:

  1. Where can I place constants that will only be used within a specific feature?
  2. Where can I place groups of TypeScript enum that will only be used within a specific feature?
  3. Where can I place groups of TypeScript enum that are going to be used throughout the entire application?

Thank you in advance, I hope to receive a response as soon as possible.

Gian López.

Hey @gianllopez , thanks for the kind words!

I think you answered the questions yourself, if it's local to a feature, keep it there. If it's only used in one place, feel free to keep it in the same file where it's used, no need to add extra files just for that. If it's reused within the feature, moving it to features/my-feature/types.ts or feautres/my-feature/constants.ts might make sense.

As for the global enum, you can have a global types.ts file where you can put all global types, similar to https://github.com/alan2207/bulletproof-react/blob/master/src/types/index.ts .