Reputation: 1250
I'm following this tutorial: https://docs.realm.io/sync/getting-started-1/react-native-quick-start/step-1-query-based-sync#step-4-create-a-constants-file-and-set-the-realm-instance-address
Many documents including this tutorial refers a src
folder, but when I create a React Native project with a command like react-native init MyProject
, it doesn't create src
folder. Why is that?
Following is my folder structure:
├── App.js
├── android
├── app.json
├── index.js
├── ios
├── node_modules
├── package.json
└── yarn.lock
Upvotes: 8
Views: 7926
Reputation: 195
Because react-native-cli does not provide src folder. It's up to you, how you design or architect your app. Directory structures are up to you and you need to write code accordingly.
Generally, project specific code is kept in the src folder. In your case, there is just one component and App.js is the only file that holds the entire code. But as there will many screens/components you will find it unmanageable. For the sake of modularity, the src folder is made and used.
App
|
|--src
|
|--assets
|--components
|--screens
|
|--loginScreen.jsx
|--homeScreen.jsx
Upvotes: 8
Reputation: 115
If you're using EXPO and wanna create the src folder to move your app directory to src/app:
Then restart the development server:
npx expo start
npx expo export
You can check it on https://docs.expo.dev/router/reference/src-directory/
Upvotes: 0
Reputation: 1158
Just manually create your src folder. It's just used to better organize your project.
Upvotes: 3