0

I am new in react-native. I am trying to develop my first app in react-native. I want to know what is the correct project structure for developing react-native apps.

As of now, I have created component in root folder. I want to know what approach should I take for defining model, utils, webservice urls in what structure.

project structure

Does it has some kinda framework as like express for creating project structure in nodejs.

5
  • 1
    have you tried searching for tutorials? Commented Apr 29, 2017 at 16:33
  • Yup. I could not find much on this Commented Apr 29, 2017 at 16:39
  • StackOverflow is not a tutorial site nor search engine replacement. We can help, but it's your job to work on this in first place. Put some efforts first. Also read How to ask, how to reward helpful answers and general StackOverflow Do and Don'ts Commented Apr 29, 2017 at 16:56
  • You could choose one of the many starter kits available and see which structure works for you. One of my fav is getpepperoni.com Commented Apr 30, 2017 at 2:28
  • Thanks. I will try it. Commented Apr 30, 2017 at 7:06

1 Answer 1

3

From my experience in building quite a large app using react-native. I have followed this approach and it scales pretty well for a team of 5+ people working on it .

enter image description here

App folder : : In this folder I keep all the files/folders related to app. Do not add anything in root folder. the less convoluted the root folder is the better for new person to get started.

uicomponents : The uicomponents folder holds all the generic controls that app needs. eg : Dropdowns, sliders, buttons, checkboxed. You can avoid this if you are using a external lib.

components : This folder holds folders for each section of screen. I call it modules for app. Each module is specific area of app, namely : HomePage, UserData, Settings so on so forth. This varies from genre of the app. My happens to be enterprise app, So I have folders for each module for an app.

Utils : I am big fan of keeping utils at one place. Things like text formatters, Db handers, Oauth Handlers and so on.

enter image description here

Stores, Dispatchers : Anything related to flux, redux can go in there.

In general the app has to be broken down in appropriate folders and files. One specific part of the app or module as I say has to have its own folder. All the files needed by him has to be in it. This makes it easy to be maintained and reasoned about.

Avoid duplicating code from beginning. Keep reusable things in Utils. All control related components (inputs, buttons, checkboxes) at one place.

Always keep styles at one place. Use constant variables for colors, this makes making changes very easy. The constant file holds colors.

enter image description here

Sign up to request clarification or add additional context in comments.

2 Comments

Does it has some kinda framework as like express for creating project structure in nodejs ?
No it does not.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.