Where must I put these files? [React, React Native]
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:
- Where can I place constants that will only be used within a specific feature?
- Where can I place groups of TypeScript
enumthat will only be used within a specific feature? - Where can I place groups of TypeScript
enumthat 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 .