Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
gianllopez opened this issue Mar 26, 2024 · 1 comment
Open

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

gianllopez opened this issue Mar 26, 2024 · 1 comment

Comments

@gianllopez
Copy link

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.

@gianllopez gianllopez changed the title ¿Donde tengo que poner estos archivos? Where must I put these files? [React, React Native] Mar 26, 2024
@alan2207
Copy link
Owner

alan2207 commented Apr 9, 2024

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 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants